Table of Contents

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

periodText string

The period string in format "number_unit"

Returns

DateTime

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

dt DateTime

The 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

text string

The date-time text to parse (e.g. "5/19/2021 09:59 AM")

Returns

DateTime

ParseDateUSA(string)

return MinValue when fail

public static DateTime ParseDateUSA(string text)

Parameters

text string

Returns

DateTime

ParseTimeUSA(string)

Parses a US time string (hh:mm tt). Seconds can be omitted.

public static DateTime ParseTimeUSA(string text)

Parameters

text string

The time text to parse (e.g. "09:30 AM")

Returns

DateTime

ToShortDateString(DateTime)

21.6.1989 / 6/21/1989

public static string ToShortDateString(DateTime today)

Parameters

today DateTime

Returns

string

ToShortDateString(DateTime, DateTime, string)

21.6.1989 / 6/21/1989

public static string ToShortDateString(DateTime today, DateTime defaultValue, string returnWhenA1isA2)

Parameters

today DateTime

DateTime to convert

defaultValue DateTime

Default DateTime value

returnWhenA1isA2 string

String to return when today equals defaultValue

Returns

string

ToShortTimeString(DateTime)

mm:ss tt

public static string ToShortTimeString(DateTime dt)

Parameters

dt DateTime

Returns

string

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

dt DateTime

Returns

string