VerityDotNet 1.0
C# library for Verity data profiling, quality control, remediation
Static Public Member Functions | List of all members
VerityDotNet.DateFuncs Class Reference

Various functions to manipulate datetime. More...

Static Public Member Functions

static List< int > GetCurrentISODateAsList (Boolean inctime=false, string tz="", double offDays=0, double offHrs=0, double offMins=0)
 Get current date or datetime in ISO format separated in a list of integers with indexing: 0=year, 1=month, 2=day and if time included: 3=hours, 4=minutes, 5=seconds.
 
static string GetCurrentISODateTime (Boolean inctime=false, string tz="", double offDays=0, double offHrs=0, double offMins=0)
 Get current date or datetime in ISO format but without delimiters like 20240409 or 20240409T090245.
 
static string IsISODateStr (string datein, bool timereq)
 Determines if string is in ISO8601 date format.
 
static bool IsYearLeap (int nyear)
 Determines is year is a leap year. Uses rule that every 4th year is leap except when multiple of 100, but when multiple of 400 it is leap.
 
static string ConvertExcelDateToISO (string excelDateString)
 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.
 
static string ConvertDateToIso (string datein, string formatin, Boolean detectFormat)
 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: ( - / _ . )
 
static bool IsDateFormat (string datein, string 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: ( - / _ . )
 

Detailed Description

Various functions to manipulate datetime.

Member Function Documentation

◆ ConvertDateToIso()

static string VerityDotNet.DateFuncs.ConvertDateToIso ( string datein,
string formatin,
Boolean detectFormat )
static

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: ( - / _ . )

Parameters
dateinincoming date string not in ISO8601 and without time part
formatinrequired 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
detectFormatoptional 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

◆ ConvertExcelDateToISO()

static string VerityDotNet.DateFuncs.ConvertExcelDateToISO ( string excelDateString)
static

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.

Parameters
excelDateStringinitial string
Returns
result as yyyyMMdd. Starts with notok: if there is an error

◆ GetCurrentISODateAsList()

static List< int > VerityDotNet.DateFuncs.GetCurrentISODateAsList ( Boolean inctime = false,
string tz = "",
double offDays = 0,
double offHrs = 0,
double offMins = 0 )
static

Get current date or datetime in ISO format separated in a list of integers with indexing: 0=year, 1=month, 2=day and if time included: 3=hours, 4=minutes, 5=seconds.

Parameters
inctimebool to include time part which comes with T prefix
tzoptional time zone offset hours as string. If empty, then ignored and local computer server setting used. From UTC (e.g. Dallas TX is -5, Kolkata India is +5.5, New York NY is -4)
offDaysoptional number of days to offset
offHrsoptional number of hours to offset
offMinsoptional number of mins to offset
Returns
list of integers. if error 0th entry = -999999

◆ GetCurrentISODateTime()

static string VerityDotNet.DateFuncs.GetCurrentISODateTime ( Boolean inctime = false,
string tz = "",
double offDays = 0,
double offHrs = 0,
double offMins = 0 )
static

Get current date or datetime in ISO format but without delimiters like 20240409 or 20240409T090245.

Parameters
inctimebool to include time part which comes with T prefix
tzoptional time zone offset hours as string. If empty, then ignored and local computer server setting used. From UTC (e.g. Dallas TX is -5, Kolkata India is +5.5, New York NY is -4)
offDaysoptional number of days to offset
offHrsoptional number of hours to offset
offMinsoptional number of mins to offset
Returns
string of time or starts with notok: if error

◆ IsDateFormat()

static bool VerityDotNet.DateFuncs.IsDateFormat ( string datein,
string formatin )
static

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: ( - / _ . )

Parameters
dateinincoming date string not in ISO8601 and without time part
formatinrequired 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

◆ IsISODateStr()

static string VerityDotNet.DateFuncs.IsISODateStr ( string datein,
bool timereq )
static

Determines if string is in ISO8601 date format.

Parameters
dateinoriginal string date
timereqBoolean whether time portion is required Thhmmss.s
Returns
string result- starts with notok: if error or false if fails test or true:newDateValue if passes

◆ IsYearLeap()

static bool VerityDotNet.DateFuncs.IsYearLeap ( int nyear)
static

Determines is year is a leap year. Uses rule that every 4th year is leap except when multiple of 100, but when multiple of 400 it is leap.

Parameters
nyearinteger year
Returns
bool

The documentation for this class was generated from the following file: