-
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.
feat(helpers): added a new category of workflow functions called help…
…ers to provide common utililites in the pipelines framework added workflow.helpers.date.get functionality
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,33 @@ | ||
"""Helper functions for working with dates and times.""" | ||
|
||
from datetime import datetime | ||
from typing import Dict | ||
|
||
|
||
def get(format: str) -> Dict[str, str]: | ||
"""Get the current date and time in the specified format. | ||
Args: | ||
format (str): The format to return the date and time in. | ||
Example: | ||
from workflow.helpers import date | ||
date.get("%Y-%m-%d %H:%M:%S") | ||
Returns: | ||
str: The current date and time. | ||
""" | ||
date = datetime.now().strftime(format) | ||
results: Dict[str, str] = {"output": date} | ||
return results | ||
|
||
|
||
def get_ctime() -> Dict[str, float]: | ||
"""Get the current time in seconds since the epoch. | ||
Returns: | ||
float: The current time in seconds since the epoch. | ||
""" | ||
ctime: float = datetime.now().timestamp() | ||
results: Dict[str, float] = {"output": ctime} | ||
return results |