C# Class Cliver.DateTimeRoutines

Miscellaneous and parsing methods for DateTime
Show file Open project: MikeJansen/DateTimeRoutines Class Usage Examples

Public Properties

Property Type Description
DefaultDateIsNow bool

Public Methods

Method Description
GetSecondsSinceUnixEpoch ( this date_time ) : uint

Amount of seconds elapsed between 1970-01-01 00:00:00 and the date-time.

TryParseDate ( this str, DateTimeFormat default_format, System.DateTime &date ) : bool

Tries to find date within the passed string and return it as DateTime structure. It recognizes only date while ignoring time, so time in the returned DateTime is always 0:0:0. If year of the date was not found then it accepts the current year.

TryParseDate ( this str, DateTimeFormat default_format, ParsedDateTime &parsed_date ) : bool

Tries to find date within the passed string and return it as ParsedDateTime object. It recognizes only date while ignoring time, so time in the returned ParsedDateTime is always 0:0:0. If year of the date was not found then it accepts the current year.

TryParseDateOrTime ( this str, DateTimeFormat default_format, System.DateTime &date_time ) : bool

Tries to find date and/or time within the passed string and return it as DateTime structure. If only date was found, time in the returned DateTime is always 0:0:0. If only time was found, date in the returned DateTime is DefaultDate.

TryParseDateOrTime ( this str, DateTimeFormat default_format, ParsedDateTime &parsed_date_time ) : bool

Tries to find date and/or time within the passed string and return it as ParsedDateTime object. If only date was found, time in the returned ParsedDateTime is always 0:0:0. If only time was found, date in the returned ParsedDateTime is DefaultDate.

TryParseDateTime ( this str, DateTimeFormat default_format, System.DateTime &date_time ) : bool

Tries to find date and time within the passed string and return it as DateTime structure.

TryParseDateTime ( this str, DateTimeFormat default_format, ParsedDateTime &parsed_date_time ) : bool

Tries to find date and time within the passed string and return it as ParsedDateTime object.

TryParseTime ( this str, DateTimeFormat default_format, System.DateTime &time ) : bool

Tries to find time within the passed string and return it as DateTime structure. It recognizes only time while ignoring date, so date in the returned DateTime is always 1/1/1.

TryParseTime ( this str, DateTimeFormat default_format, ParsedDateTime &parsed_time ) : bool

Tries to find time within the passed string and return it as ParsedDateTime object. It recognizes only time while ignoring date, so date in the returned ParsedDateTime is always 1/1/1

TryParseTime ( this str, DateTimeFormat default_format, ParsedDateTime &parsed_time, ParsedDateTime parsed_date ) : bool

Tries to find time within the passed string (relatively to the passed parsed_date if any) and return it as ParsedDateTime object. It recognizes only time while ignoring date, so date in the returned ParsedDateTime is always 1/1/1

Private Methods

Method Description
convert_to_date ( int year, int month, int day, System.DateTime &date ) : bool

Method Details

GetSecondsSinceUnixEpoch() public static method

Amount of seconds elapsed between 1970-01-01 00:00:00 and the date-time.
public static GetSecondsSinceUnixEpoch ( this date_time ) : uint
date_time this date-time
return uint

TryParseDate() public static method

Tries to find date within the passed string and return it as DateTime structure. It recognizes only date while ignoring time, so time in the returned DateTime is always 0:0:0. If year of the date was not found then it accepts the current year.
public static TryParseDate ( this str, DateTimeFormat default_format, System.DateTime &date ) : bool
str this string that contains date
default_format System.DateTimeFormat format to be used preferably in ambivalent instances
date System.DateTime parsed date output
return bool

TryParseDate() public static method

Tries to find date within the passed string and return it as ParsedDateTime object. It recognizes only date while ignoring time, so time in the returned ParsedDateTime is always 0:0:0. If year of the date was not found then it accepts the current year.
public static TryParseDate ( this str, DateTimeFormat default_format, ParsedDateTime &parsed_date ) : bool
str this string that contains date
default_format System.DateTimeFormat format to be used preferably in ambivalent instances
parsed_date ParsedDateTime parsed date output
return bool

TryParseDateOrTime() public static method

Tries to find date and/or time within the passed string and return it as DateTime structure. If only date was found, time in the returned DateTime is always 0:0:0. If only time was found, date in the returned DateTime is DefaultDate.
public static TryParseDateOrTime ( this str, DateTimeFormat default_format, System.DateTime &date_time ) : bool
str this string that contains date and(or) time
default_format System.DateTimeFormat format to be used preferably in ambivalent instances
date_time System.DateTime parsed date-time output
return bool

TryParseDateOrTime() public static method

Tries to find date and/or time within the passed string and return it as ParsedDateTime object. If only date was found, time in the returned ParsedDateTime is always 0:0:0. If only time was found, date in the returned ParsedDateTime is DefaultDate.
public static TryParseDateOrTime ( this str, DateTimeFormat default_format, ParsedDateTime &parsed_date_time ) : bool
str this string that contains date-time
default_format System.DateTimeFormat format to be used preferably in ambivalent instances
parsed_date_time ParsedDateTime parsed date-time output
return bool

TryParseDateTime() public static method

Tries to find date and time within the passed string and return it as DateTime structure.
public static TryParseDateTime ( this str, DateTimeFormat default_format, System.DateTime &date_time ) : bool
str this string that contains date and/or time
default_format System.DateTimeFormat format to be used preferably in ambivalent instances
date_time System.DateTime parsed date-time output
return bool

TryParseDateTime() public static method

Tries to find date and time within the passed string and return it as ParsedDateTime object.
public static TryParseDateTime ( this str, DateTimeFormat default_format, ParsedDateTime &parsed_date_time ) : bool
str this string that contains date-time
default_format System.DateTimeFormat format to be used preferably in ambivalent instances
parsed_date_time ParsedDateTime parsed date-time output
return bool

TryParseTime() public static method

Tries to find time within the passed string and return it as DateTime structure. It recognizes only time while ignoring date, so date in the returned DateTime is always 1/1/1.
public static TryParseTime ( this str, DateTimeFormat default_format, System.DateTime &time ) : bool
str this string that contains time
default_format System.DateTimeFormat format to be used preferably in ambivalent instances
time System.DateTime parsed time output
return bool

TryParseTime() public static method

Tries to find time within the passed string and return it as ParsedDateTime object. It recognizes only time while ignoring date, so date in the returned ParsedDateTime is always 1/1/1
public static TryParseTime ( this str, DateTimeFormat default_format, ParsedDateTime &parsed_time ) : bool
str this string that contains date-time
default_format System.DateTimeFormat format to be used preferably in ambivalent instances
parsed_time ParsedDateTime parsed date-time output
return bool

TryParseTime() public static method

Tries to find time within the passed string (relatively to the passed parsed_date if any) and return it as ParsedDateTime object. It recognizes only time while ignoring date, so date in the returned ParsedDateTime is always 1/1/1
public static TryParseTime ( this str, DateTimeFormat default_format, ParsedDateTime &parsed_time, ParsedDateTime parsed_date ) : bool
str this string that contains date
default_format System.DateTimeFormat format to be used preferably in ambivalent instances
parsed_time ParsedDateTime parsed date-time output
parsed_date ParsedDateTime ParsedDateTime object if the date was found within this string, else NULL
return bool

Property Details

DefaultDateIsNow public static property

If true then DefaultDate property is ignored and DefaultDate is always DateTime.Now
public static bool DefaultDateIsNow
return bool