Skip to content

Commit

Permalink
feat(helpers): added a new category of workflow functions called help…
Browse files Browse the repository at this point in the history
…ers to provide common utililites in the pipelines framework

added workflow.helpers.date.get functionality
  • Loading branch information
shinybrar committed Jun 26, 2024
1 parent 1836cf1 commit bb3659b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Empty file added workflow/helpers/__init__.py
Empty file.
33 changes: 33 additions & 0 deletions workflow/helpers/date.py
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

0 comments on commit bb3659b

Please sign in to comment.