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
XItWasNotMentioned
Localization string for "it was not mentioned" status.
public static string XItWasNotMentioned
Field Value
XNoKnownPeriod
Localization string for unknown time period.
public static string XNoKnownPeriod
Field Value
XNotIndicated
Localization string for "not indicated" status.
public static string XNotIndicated
Field Value
lastDateTime
Stores the last successfully parsed DateTime value from TryParseDateTime.
public DateTime lastDateTime
Field Value
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
timeSpanTimeSpanThe time span to describe
calculateTimeboolWhether to include sub-day time units
langLangsDtThe language for localization
Returns
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
dateTimeDateTimeThe DateTime to format
langLangsDtThe language determining the format
dtMinValDateTimeThe minimum DateTime value representing an unset date
Returns
DateToString(DateTime, LangsDt)
21.6.1989 / 6/21/1989
public static string DateToString(DateTime dateTime, LangsDt lang)
Parameters
Returns
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
dateTimeDateTimeThe DateTime to format
langLangsDtThe language determining the format
dtMinValDateTimeThe minimum DateTime value representing an unset date
Returns
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
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
Returns
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
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
textstring
Returns
IsValidDateTimeText(string)
A1 can be in en or cs parse time after first space
public static DateTime IsValidDateTimeText(string text)
Parameters
textstring
Returns
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
textstringThe 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
Returns
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
dateTextstringThe date text to parse
dayToint?Output: the end day if a day range was specified, otherwise -1
Returns
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
dateTimeDateTimeThe DateTime whose time to format
langLangsDtThe language for localization
dtMinValDateTimeThe 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
rstringThe text to parse as date-time, date, or time
Returns
- bool
True if parsing succeeds, false otherwise