VerityPy 1.1
Python library for Verity data profiling, quality control, remediation
|
Functions | |
str | get_current_iso_datetime (bool inctime=False, str tz="") |
str | is_iso_date_str (str strin, bool timereq=False) |
str | convert_excel_date_to_iso (str strin) |
bool | is_year_leap (int nyear) |
str | convert_date_to_iso (str datein, str formatin, bool detectfmt=False) |
bool | is_date_format (str datein, str formatin) |
Date Functions various functions to process and provide dates
str convert_date_to_iso | ( | str | datein, |
str | formatin, | ||
bool | detectfmt = False ) |
Converts a datetime into ISO8601 format based on specified format. Time portions should be removed prior to sending into this method. Four delimiters in date part will be automatically detected: ( - / _ . ) datein: incoming date string not in ISO8601 and without time part. formatin: required unless detectfmt is True mmddyy, mmdyy, mdyy, mmddyyyy, mmdyyyy, mdyyyy, ddmmyy, ddmyy, dmyy, ddmmyyyy, ddmyyyy, dmyyyy, yymmdd, yymmd, yymd, yyyymmdd, yyyymmd, yyyymd, yyyyddd (3 digit day number within year), yyyyMMMdd, ddMMMyyyy (MMM = 3 letter month title like 'JAN'), 'MONTHdd,yyyy', 'ddMONTH,yyyy', yyyyMONTHdd, ddMONTHyyyy, yyMONTHdd, ddMONTHyy (MONTH full title), *dmmyyyy, mm*dyyyy, *mddyyyy, dd*myyyy (*= can be 1 or 2 characters) With these formats, incoming string must have all characters required so for mmddyyyy there must be 8 characters meaning 1122011 fails but 01122011 is good. Leading title of day is removed like for Wednesday, March 14, 2001 which will be changed to March 14, 2001 and then will match formatin of MONTHdd,yyyy since spaces are removed detectfmt: optional bool when True the format will be detected if possible. To do so, the date part should have a delimiter ( / - ) like 12/20/2021 or 2024-04-02, and preferably where day value is unambiguous relative to month (i.e. > 12 ) Returns - result as yyyymmdd with suffix (dateformat) if detectfmt=True. Starts with 'notok:' if there is an error
Definition at line 386 of file datefuncs.py.
str convert_excel_date_to_iso | ( | str | strin | ) |
Excel numeric date to ISO format Converts a date in numeric excel format into ISO8601 yyyyMMdd format. Fractional days are removed. Jan 1 1900 is 1. Anything less than 1 is error. Example: 44106 = 20201002, 45393 = 20240411, 21012=19570711 Return result as yyyyMMdd. Starts with notok: if there is an error
Definition at line 255 of file datefuncs.py.
str get_current_iso_datetime | ( | bool | inctime = False, |
str | tz = "" ) |
Get current date or datetime in ISO format but without delimiters like 20240409 or 20240409T090245 inctime: bool whether to include time part with T prefix tz: optional number hours timezone offset from UTC (e.g. Dallas TX is -5, Kolkata India is +5.5, New York NY is -4), otherwise the computer's time zone is used so depends on server settings. Returns string starting with notok: if error
Definition at line 27 of file datefuncs.py.
bool is_date_format | ( | str | datein, |
str | formatin ) |
Determines if date string is in specified format. Time portions should be removed prior to sending into this method. Four delimiters in date part will be automatically detected: ( - / _ . ) datein: incoming date string without time part. formatin: required mmddyy, mmdyy, mdyy, mmddyyyy, mmdyyyy, mdyyyy, ddmmyy, ddmyy, dmyy, ddmmyyyy, ddmyyyy, dmyyyy, yymmdd, yymmd, yymd, yyyymmdd, yyyymmd, yyyymd, yyyyddd (3 digit day number within year), yyyyMMMdd, ddMMMyyyy (MMM = 3 letter month title like 'JAN'), 'MONTHdd,yyyy', 'ddMONTH,yyyy', yyyyMONTHdd, ddMONTHyyyy, yyMONTHdd, ddMONTHyy (MONTH full title), *dmmyyyy, mm*dyyyy, *mddyyyy, dd*myyyy (*= can be 1 or 2 characters) With these formats, incoming string must have all characters required so for mmddyyyy there must be 8 characters meaning 1122011 fails but 01122011 is good. Leading title of day is removed like for Wednesday, March 14, 2001 which will be changed to March 14, 2001 and then will match formatin of MONTHdd,yyyy since spaces are removed Returns - bool True/False
Definition at line 1085 of file datefuncs.py.
str is_iso_date_str | ( | str | strin, |
bool | timereq = False ) |
Determines if string is an ISO DateTime timereq: bool if time part is required. This is demarcated by either T or a space after the date part as with 20240420T0730 or 20240420 0730 All delimiters will be removed (- /) in date part, (:) in time part. Returns string as either false or true:<newdatetime>, or starts with notok: if error
Definition at line 56 of file datefuncs.py.
bool is_year_leap | ( | int | nyear | ) |
Is Year a Leap Year uses rule that every 4th year is leap except when multiple of 100, but when multiple of 400 it is leap nyear: integer year to evaluate returns: bool
Definition at line 364 of file datefuncs.py.