generated from nathanwoodburn/python-webserver-template
feat: Remove tz from output time
All checks were successful
Build Docker / BuildImage (push) Successful in 30s
All checks were successful
Build Docker / BuildImage (push) Successful in 30s
This commit is contained in:
@@ -159,7 +159,7 @@ def convert():
|
|||||||
return jsonify(
|
return jsonify(
|
||||||
{
|
{
|
||||||
"from": from_tz_time.strftime("%Y-%m-%d %H:%M:%S %Z"),
|
"from": from_tz_time.strftime("%Y-%m-%d %H:%M:%S %Z"),
|
||||||
"to": to_tz_time.strftime("%Y-%m-%d %H:%M:%S %Z"),
|
"to": to_tz_time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -187,10 +187,7 @@ def convert_multiple():
|
|||||||
results = {}
|
results = {}
|
||||||
for original_tz, tz in to_tz_list:
|
for original_tz, tz in to_tz_list:
|
||||||
to_tz_time = from_tz_time.astimezone(tz)
|
to_tz_time = from_tz_time.astimezone(tz)
|
||||||
offset = to_tz_time.strftime('%z')
|
results[original_tz] = f"{to_tz_time.strftime('%Y-%m-%d %H:%M:%S')}"
|
||||||
offset_formatted = f"UTC{offset[:3]}:{offset[3:]}" if offset else ""
|
|
||||||
tz_name = to_tz_time.tzname() if to_tz_time.tzname() else offset_formatted
|
|
||||||
results[original_tz] = f"{to_tz_time.strftime('%Y-%m-%d %H:%M:%S')} {tz_name}"
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({"error": str(e)}), 400
|
return jsonify({"error": str(e)}), 400
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user