-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ac52cf
commit e586941
Showing
2 changed files
with
131 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from datetime import datetime | ||
import pytz | ||
|
||
|
||
def convert_date_format(date_str: str) -> str: | ||
""" | ||
Convertit une date du format "DD/MM/YYYY HH:MM:SS" vers le format ISO "YYYY-MM-DDThh:mm:ss.000Z" | ||
Args: | ||
date_str (str): Date au format "DD/MM/YYYY HH:MM:SS" | ||
Returns: | ||
str: Date au format ISO "YYYY-MM-DDThh:mm:ss.000Z" | ||
""" | ||
try: | ||
date_obj = datetime.strptime(date_str, "%d/%m/%Y %H:%M:%S") | ||
|
||
utc_date = pytz.utc.localize(date_obj) | ||
|
||
iso_date = utc_date.strftime("%Y-%m-%dT%H:%M:%S.000Z") | ||
|
||
return iso_date | ||
except (ValueError, TypeError): | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters