Show current local time default when adding new reading
This commit is contained in:
@@ -275,6 +275,12 @@ def add_reading():
|
||||
db.session.commit()
|
||||
flash("Reading added successfully.", "success")
|
||||
return redirect(url_for('main.dashboard'))
|
||||
|
||||
# Fetch the user's timezone (default to 'UTC' if none is set)
|
||||
user_timezone = current_user.profile.timezone if current_user.profile and current_user.profile.timezone else 'UTC'
|
||||
local_tz = timezone(user_timezone)
|
||||
|
||||
form.timestamp.data = utc.localize(datetime.utcnow()).astimezone(local_tz)
|
||||
return render_template('add_reading.html', form=form)
|
||||
|
||||
@main.route('/reading/<int:reading_id>/edit', methods=['GET', 'POST'])
|
||||
|
||||
Reference in New Issue
Block a user