Table of Contents

Class DTHelperMulti

Namespace
SunamoDateTime.DT
Assembly
SunamoDateTime.dll

Provides multi-language DateTime formatting, parsing and utility methods supporting both Czech and English locales.

public class DTHelperMulti
Inheritance
DTHelperMulti
Inherited Members
Extension Methods

Fields

XFilesFounded

Localization string for "files founded" in English.

public static string XFilesFounded

Field Value

string

XItWasNotMentioned

Localization string for "it was not mentioned" status.

public static string XItWasNotMentioned

Field Value

string

XNoKnownPeriod

Localization string for unknown time period.

public static string XNoKnownPeriod

Field Value

string

XNotIndicated

Localization string for "not indicated" status.

public static string XNotIndicated

Field Value

string

lastDateTime

Stores the last successfully parsed DateTime value from TryParseDateTime.

public DateTime lastDateTime

Field Value

DateTime

Methods

AddRightStringToTimeSpan(TimeSpan, bool, LangsDt)

Appends the appropriate localized time unit string to a TimeSpan value. Returns "~1 day" if the span is less than 1 day and calculateTime is false.

public static string AddRightStringToTimeSpan(TimeSpan timeSpan, bool calculateTime, LangsDt lang)

Parameters

timeSpan TimeSpan

The time span to describe

calculateTime bool

Whether to include sub-day time units

lang LangsDt

The language for localization

Returns

string

DateTimeToString(DateTime, LangsDt, DateTime)

Formats a DateTime as a localized date-time string (cs: 21.6.1989 11:22, en: 6/21/1989 11:22). Returns "not indicated" text if equal to minimum value.

public static string DateTimeToString(DateTime dateTime, LangsDt lang, DateTime dtMinVal)

Parameters

dateTime DateTime

The DateTime to format

lang LangsDt

The language determining the format

dtMinVal DateTime

The minimum DateTime value representing an unset date

Returns

string

DateToString(DateTime, LangsDt)

21.6.1989 / 6/21/1989

public static string DateToString(DateTime dateTime, LangsDt lang)

Parameters

dateTime DateTime
lang LangsDt

Returns

string

DateToStringOrSE(DateTime, LangsDt, DateTime)

Formats a DateTime as a localized date string (21.6.1989 / 6/21/1989), or returns empty string if equal to minimum value.

public static string DateToStringOrSE(DateTime dateTime, LangsDt lang, DateTime dtMinVal)

Parameters

dateTime DateTime

The DateTime to format

lang LangsDt

The language determining the format

dtMinVal DateTime

The minimum DateTime value representing an unset date

Returns

string

DateToStringWithDayOfWeek(DateTime, LangsDt)

Formats a DateTime as a localized date string with day of week prefix (e.g. "Středa, 21.6.1989" / "Wednesday, 6/21/1989").

public static string DateToStringWithDayOfWeek(DateTime dateTime, LangsDt lang)

Parameters

dateTime DateTime

The DateTime to format

lang LangsDt

The language determining the format

Returns

string

Date string with day of week prefix

DateWithDayOfWeek(DateTime, LangsDt)

21.6.1989 (středa) / 6/21/1989 (wednesday)

public static string DateWithDayOfWeek(DateTime dateTime, LangsDt lang)

Parameters

dateTime DateTime
lang LangsDt

Returns

string

FilesFounded(int, LangsDt)

Returns the localized string for "files found" with proper Czech declension based on count.

public static string FilesFounded(int count, LangsDt lang)

Parameters

count int

The number of files found

lang LangsDt

The language for localization

Returns

string

Localized "files found" string

IsValidDateText(string)

Return whether can be parse with DTHelperCs.ParseDateCzech or DTHelperEn.ParseDateUSA

public static DateTime IsValidDateText(string text)

Parameters

text string

Returns

DateTime

IsValidDateTimeText(string)

A1 can be in en or cs parse time after first space

public static DateTime IsValidDateTimeText(string text)

Parameters

text string

Returns

DateTime

IsValidTimeText(string)

Validates whether the text represents a valid time (Czech hh:mm:ss or US hh:mm tt format).

public static DateTime IsValidTimeText(string text)

Parameters

text string

The time text to validate

Returns

DateTime

Parsed DateTime if valid, DateTime.MinValue otherwise

OperationLastedInLocalizateString(TimeSpan, LangsDt)

Returns a localized string describing how long an operation lasted, from hours down to milliseconds.

public static string OperationLastedInLocalizateString(TimeSpan timeSpan, LangsDt lang)

Parameters

timeSpan TimeSpan

The duration of the operation

lang LangsDt

The language for localization

Returns

string

ParseDateMonthDayYear(string, out int?)

Parses a date in month/day/year or day.month.year format. Supports day ranges with dash.

public static DateTime? ParseDateMonthDayYear(string dateText, out int? dayTo)

Parameters

dateText string

The date text to parse

dayTo int?

Output: the end day if a day range was specified, otherwise -1

Returns

DateTime?

TimeToString(DateTime, LangsDt, DateTime)

Formats a DateTime's time component as a localized string (HH:mm), or returns "not indicated" if equal to minimum value.

public static string TimeToString(DateTime dateTime, LangsDt lang, DateTime dtMinVal)

Parameters

dateTime DateTime

The DateTime whose time to format

lang LangsDt

The language for localization

dtMinVal DateTime

The minimum DateTime value representing an unset date

Returns

string

Formatted time string or localized "not indicated" text

TryParseDateTime(string)

Tries to parse a date-time, date, or time text. Result is stored in lastDateTime property.

public bool TryParseDateTime(string r)

Parameters

r string

The text to parse as date-time, date, or time

Returns

bool

True if parsing succeeds, false otherwise