datetime_interface#
- tools.datetime_interface.compare_crontab(datestr, cronstr, frmttyp)[source]#
DESCRIPTION:
This function compares the user-specified date to the a crontab formatted value and returns a boolean value specifying whether the crontab string (specifying when to execute an action) and user-specified date match.
- Parameters:
- datestr:
str A Python string containing a date string.
- cronstr:
str A Python string specifying a crontab formatted date string for which to perform an action.
- frmttyp:
str A Python string specifying the format of the timestamps string; this assumes POSIX convention date attribute characters.
- datestr:
- Returns:
- crontab_match:
bool A Python boolean valued variable specifying whether the crontab string (specifying when to execute an action) and a date match.
- crontab_match:
- Return type:
bool
- tools.datetime_interface.current_date(frmttyp, is_utc=True)[source]#
DESCRIPTION:
This function returns the current time (at invocation of this function) formatted according to the parameter values specified upon entry.
- Parameters:
- frmttyp:
str A Python string specifying the format of the output timestamp string; this assumes POSIX convention date attribute characters.
- frmttyp:
- Keywords:
- is_utc:
bool, optional A Python boolean valued variable specifying whether to return the current date/timestamp in Coordinated Universal Time.
- is_utc:
- Returns:
- timestamp:
str A Python string containing the current time (at invocation of this function) formatted according to the user specifications.
- timestamp:
- Return type:
str
- tools.datetime_interface.datestrcomps(datestr, frmttyp)[source]#
DESCRIPTION:
This function returns a Python object containing the specified date string component values; the following attributes are returned: :rtype:
SimpleNamespaceyear (year)
month of year (month)
day of month (day)
hour of day (hour)
minute of hour (minute)
second of minute (second)
full month name (month_name_long)
abbreviated month name (month_name_short)
full day name (weekday_long)
abbreviated day name (weekday_short)
2-digit century (e.g., 2015 is 20; century_short)
2-digit year (e.g., year without the century value; year_short)
date string (date_string; formatted as %Y-%m-%d_%H:%M:%S, assuming the POSIX convention)
cycle string (cycle_string; formatted as %Y%m%d%H, assuming the POSIX convention)
Julian date (julian_day)
The HH:MM:SS as the total elapsed seconds, formatted as 5-digit integer (total_seconds_of_day)
The day of the year (day_of_year); begins from day 1 of respective year.
epoch (seconds since 0000 UTC 01 January 1970).
- Parameters:
- datestr:
str A Python string containing a date string.
- frmttyp:
str A Python string specifying the format for the input date string (datestr).
- datestr:
- Returns:
- date_comps_obj:
SimpleNamespace A Python SimpleNamespace object containing the date string component values for the user specfied date string.
- date_comps_obj:
- tools.datetime_interface.datestrfrmt(datestr, frmttyp, offset_seconds=None)[source]#
DESCRIPTION:
This function ingests a date string and computes and returns a (newly/different) formatted date string; the format of the respective date string is defined by the frmttyp parameter specified upon entry; an optional keyword offset_seconds defines a datestr relative to the value for parameter datestr and the the specified number of seconds; both positive and negative values for offset_seconds is supported.
- Parameters:
- datestr:
str A Python string containing a date string; the input date string is assumed to have format %Y-%m-%d_%H:%M:%S assuming the POSIX convention.
- frmttyp:
str A Python string specifying the format of the timestamps string; this assumes POSIX convention date attribute characters.
- datestr:
- Keywords:
- offset_seconds:
int, optional A Python integer defining the total number of offset-seconds relative to the datestr variable (see above) for the output time-stamp/date-string; the default is NoneType.
- offset_seconds:
- Returns:
- outdatestr:
str A Python string containing the appropriately formatted time-stamp/date-string.
- outdatestr:
- Return type:
str
- tools.datetime_interface.datestrupdate(datestr, in_frmttyp, out_frmttyp, offset_seconds=None)[source]#
DESCRIPTION:
This function ingests a date string and an optional argument offset_seconds to define a new datestr relative to the user provided datestr and the number of seconds and the input and output date string formats; this function also permits non-POSIX standard time attributes, as determined by datestrcomps (above) and user specified template values (denoted between < > in the out_frmttyp parameter).
- Parameters:
- datestr:
str A Python string containing a date string of format in_frmttyp (see below).
- in_frmttyp:
str A Python string specifying the POSIX convention for the datestr variable upon input.
- out_frmttyp:
str A Python string specifying the POSIX convention for the datestr variable upon output.
- datestr:
- Keywords:
- offset_seconds:
int, optional A Python integer defining the total number of offset-seconds relative to the datestr variable(see above) for the output time-stamp/date-string; the default is NoneType.
- offset_seconds:
- Returns:
- outdatestr:
str A Python string containing the appropriately formatted time-stamp/date-string.
- outdatestr:
- Return type:
str
- tools.datetime_interface.elapsed_seconds(start_datestr, start_frmttyp, stop_datestr, stop_frmttyp)[source]#
DESCRIPTION:
This function computes and returns the total number of seconds (e.g., the difference) between two input date strings.
- Parameters:
- start_datestr:
str A Python string containing a date string of format start_frmttyp (below).
- start_frmttyp:
str A Python string specifying the POSIX convention for the start_datestr variable.
- stop_datestr:
str A Python string containing a date string of format stop_frmttyp (below).
- stop_frmttyp:
str A Python string specifying the POSIX convention for the stop_datestr variable.
- start_datestr:
- Returns:
- seconds:
float A Python float value specifying the total number of seconds between the two input date strings.
- seconds:
- Return type:
float
- tools.datetime_interface.epoch_to_datestr(epoch_seconds, out_frmttyp=None)[source]#
DESCRIPTION:
This function transforms the epoch time (e.g., the number of seconds relative to 0000 UTC 01 January 1970) to the (optional) date-string format (out_frmttyp).
- Parameters:
- epoch_seconds:
int A Python integer specifying the epoch seconds.
- epoch_seconds:
- Keywords:
- out_frmttyp:
str, optional A Python string defining the date-string format for the epoch time format.
- out_frmttyp:
- Returns:
- epoch_datestr:
str A Python string defining the epoch time (seconds) represented as date-string characters.
- epoch_datestr:
- Return type:
str