Class DTHelperEn
- Namespace
- SunamoDateTime.DT
- Assembly
- SunamoDateTime.dll
Provides English/US-localized DateTime formatting and parsing methods.
public class DTHelperEn
- Inheritance
-
DTHelperEn
- Inherited Members
- Extension Methods
Methods
CalculateStartOfPeriod(string)
Calculates a past date by subtracting the specified period from today. Input format: "{number}_{days|weeks|years|months}" (e.g. "7_days", "2_weeks").
public static DateTime CalculateStartOfPeriod(string periodText)
Parameters
periodTextstringThe period string in format "number_unit"
Returns
DateToStringWithDayOfWeekEN(DateTime)
Formats a DateTime as an English date string with day of week prefix (e.g. "Wednesday, 6/21/1989").
public static string DateToStringWithDayOfWeekEN(DateTime dt)
Parameters
dtDateTimeThe DateTime to format
Returns
- string
English-formatted date string with day of week
ParseDateTimeUSA(string)
Parses a US date-time string (mm/dd/yyyy hh:mm tt). Seconds can be omitted.
public static DateTime ParseDateTimeUSA(string text)
Parameters
textstringThe date-time text to parse (e.g. "5/19/2021 09:59 AM")
Returns
ParseDateUSA(string)
return MinValue when fail
public static DateTime ParseDateUSA(string text)
Parameters
textstring
Returns
ParseTimeUSA(string)
Parses a US time string (hh:mm tt). Seconds can be omitted.
public static DateTime ParseTimeUSA(string text)
Parameters
textstringThe time text to parse (e.g. "09:30 AM")
Returns
ToShortDateString(DateTime)
21.6.1989 / 6/21/1989
public static string ToShortDateString(DateTime today)
Parameters
todayDateTime
Returns
ToShortDateString(DateTime, DateTime, string)
21.6.1989 / 6/21/1989
public static string ToShortDateString(DateTime today, DateTime defaultValue, string returnWhenA1isA2)
Parameters
todayDateTimeDateTime to convert
defaultValueDateTimeDefault DateTime value
returnWhenA1isA2stringString to return when today equals defaultValue
Returns
ToShortTimeString(DateTime)
mm:ss tt
public static string ToShortTimeString(DateTime dt)
Parameters
dtDateTime
Returns
ToString(DateTime)
Its named ToString due to exactly same format return dt.ToString while is en-us localization 21.6.1989 / 6/21/1989 + " " + mm:ss tt
public static string ToString(DateTime dt)
Parameters
dtDateTime