Skip to content

Commit

Permalink
Merge pull request #305 from ifpen:feat/set_iso_date
Browse files Browse the repository at this point in the history
feat: set return the date and time in ISO 8601 format for default xprjson
  • Loading branch information
GhilesHideur committed Apr 30, 2024
2 parents a70466e + e4662a5 commit 4fb0ae0
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions back_end/taipy/utils_xprjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,23 @@
from datetime import datetime
import pytz

def _getDateTime():

def _get_date_time():
# Choose the timezone
timezone = pytz.timezone('Europe/Paris')
# Get the current date and time in the specified timezone
timezone = pytz.timezone("Europe/Paris")
current_time = datetime.now(timezone)
# Format the date and time
formatted_time = current_time.strftime('%a %b %d %Y %H:%M:%S GMT%z')
# Adjust the format to include a colon in the timezone part
formatted_time_with_colon = formatted_time[:-2] + ':' + formatted_time[-2:]
# Return the date and time in ISO 8601 format
return current_time.isoformat()

return formatted_time_with_colon

def _remove_extension(filename, extension=".xprjson"):
if filename.endswith(extension):
return filename[:-len(extension)]
return filename[: -len(extension)]
return filename


def update_xprjson(xprjson, name):
xprjson['meta']['date'] = _getDateTime()
xprjson['meta']['name'] = _remove_extension(name)
return xprjson
xprjson["meta"]["date"] = _get_date_time()
xprjson["meta"]["name"] = _remove_extension(name)

return xprjson

0 comments on commit 4fb0ae0

Please sign in to comment.