Class TimeGlobalizationInfo
Strategy object that determines how controls interact with DateTime and CultureInfo.
Inheritance
Inherited Members
Namespace: System.Windows.Controls
Assembly: OpenSilver.Controls.Input.Toolkit.dll
Syntax
public class TimeGlobalizationInfo
Remarks
TimeInput supports only the following formatting characters: 'h', 'm', 's', 'H', 't'. All other characters are filtered out: 'd', 'f', 'F', 'g', 'K', 'M', 'y', 'z'.
Properties
| Improve this Doc View SourceActualCulture
Gets the actual culture used by the TimeGlobalizationInfo for formatting and parsing.
Declaration
public CultureInfo ActualCulture { get; }
Property Value
Type | Description |
---|---|
System.Globalization.CultureInfo | The actual culture. |
AMDesignator
Gets the string designator for hours that are "ante meridiem" (before noon).
Declaration
public virtual string AMDesignator { get; }
Property Value
Type | Description |
---|---|
System.String | The AM designator. |
PMDesignator
Gets the string designator for hours that are "post meridiem" (after noon).
Declaration
public virtual string PMDesignator { get; }
Property Value
Type | Description |
---|---|
System.String | The PM designator. |
TimeSeparators
Gets the characters that may be used to separate components of time, that is, hours, minutes and seconds.
Declaration
public virtual IList<char> TimeSeparators { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IList<System.Char> |
Methods
| Improve this Doc View SourceFormatTime(Nullable<DateTime>, ITimeFormat, Char[])
Formats the specified DateTime to a time string representation.
Declaration
public virtual string FormatTime(DateTime? value, ITimeFormat timeFormat, params char[] timeCharacters)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.DateTime> | value | The DateTime that should be formatted. |
ITimeFormat | timeFormat | The time format used to describe how value should be formatted. |
System.Char[] | timeCharacters | The allowed characters in the format. Leave empty to indicate that all characters are allowed. See remarks. |
Returns
Type | Description |
---|---|
System.String | A string that represents the time part of a DateTime. |
Remarks
The TimeFormat will contain TimeCharacters in a certain order, like hh:mm:ss. By passing specific TimeCharacters, these will get filtered and the method only returns part of the formatted string. Example: pass 'h', 't', 'H' to get back 4 AM, if the culture was set to en-US.
GetActualTimeParsers(IEnumerable<TimeParser>)
Gets the actual TimeParsers that will be used for parsing.
Declaration
public virtual IEnumerable<TimeParser> GetActualTimeParsers(IEnumerable<TimeParser> parsers)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TimeParser> | parsers | The parsers that are currently used by parent. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TimeParser> | A new collection of parsers that represent the parsers this strategy object will use. |
GetTextPositionForTimeUnit(String, TimeSpan, ITimeFormat)
Gets the position for a time unit in a string that can be parsed by the specified ITimeFormat.
Declaration
public virtual int GetTextPositionForTimeUnit(string text, TimeSpan timeSpan, ITimeFormat timeFormat)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text that represents a DateTime. |
System.TimeSpan | timeSpan | The time span that is searched for. |
ITimeFormat | timeFormat | The time format that describes how this text can be parsed to a DateTime. |
Returns
Type | Description |
---|---|
System.Int32 | The position in the text that corresponds to the TimeSpan or -1 if none was found. |
GetTimeUnitAtTextPosition(String, Int32, ITimeFormat)
Gets the time unit that is represented by a text position.
Declaration
public virtual TimeSpan GetTimeUnitAtTextPosition(string text, int textPosition, ITimeFormat timeFormat)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text that represents a DateTime. |
System.Int32 | textPosition | The location in the text. |
ITimeFormat | timeFormat | The time format describe how the text can be parsed to a DateTime. |
Returns
Type | Description |
---|---|
System.TimeSpan | The TimeSpan that is represented by the character at a specific caret position. |
GetTransformedFormat(String)
Transforms a format to a format that only allows the characters h, m, s, t, H and the defined TimeSeparators (: and .). Also takes into account the rule that a single TimeCharacter should be followed by a space.
Declaration
protected virtual string GetTransformedFormat(string format)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | The format that needs to be transformed. |
Returns
Type | Description |
---|---|
System.String | A format containing only the expected characters. |
MapCharacterToDigit(Char)
Returns the European number character of each global representation parsed by the TimeGlobalizationInfo.
Declaration
protected virtual char MapCharacterToDigit(char input)
Parameters
Type | Name | Description |
---|---|---|
System.Char | input | The global version of the character that needs to be mapped to a regular character. |
Returns
Type | Description |
---|---|
System.Char | The character that represents the global version of a character. |
Remarks
All characters pass through this method (whitespaces and TimeDesignators). Return the input character if no logical mapping could be made.
MapDigitToCharacter(Int32)
Returns the global representation of each integer formatted by the TimeGlobalizationInfo.
Declaration
protected virtual char MapDigitToCharacter(int input)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | input | Character that will be mapped to a different character. |
Returns
Type | Description |
---|---|
System.Char | The global version of a character that represents the input. |
OnDecrement(DateTime, TimeSpan)
Subtracts a time span from a date time in a global context.
Declaration
public virtual DateTime OnDecrement(DateTime value, TimeSpan timeSpan)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | value | The value. |
System.TimeSpan | timeSpan | The time span. |
Returns
Type | Description |
---|---|
System.DateTime | The DateTime after decrementing by TimeSpan. |
OnIncrement(DateTime, TimeSpan)
Performs addition of a date time and a time span in a global context.
Declaration
public virtual DateTime OnIncrement(DateTime value, TimeSpan timeSpan)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | value | The value. |
System.TimeSpan | timeSpan | The time span. |
Returns
Type | Description |
---|---|
System.DateTime | The DateTime after incrementing by TimeSpan. |
ParseTime(String, ITimeFormat, IEnumerable<TimeParser>)
Parses a string into a DateTime using the specified ITimeFormat instance and TimeParsers.
Declaration
public DateTime? ParseTime(string mappedText, ITimeFormat timeFormat, IEnumerable<TimeParser> timeParsers)
Parameters
Type | Name | Description |
---|---|---|
System.String | mappedText | The text that was entered by the user. |
ITimeFormat | timeFormat | The TimeFormat instance used to supply formats. |
System.Collections.Generic.IEnumerable<TimeParser> | timeParsers | The time parsers. |
Returns
Type | Description |
---|---|
System.Nullable<System.DateTime> | A DateTime with a correctly set time part. |
Remarks
The date part of the DateTime is irrelevant and will be overwritten by the current date.
TryParseTime(String, ITimeFormat, IEnumerable<TimeParser>, out Nullable<DateTime>)
Parses a string into a DateTime using the specified ITimeFormat instance and TimeParsers and returns a value that indicates whether the conversion succeeded.
Declaration
public bool TryParseTime(string mappedText, ITimeFormat timeFormat, IEnumerable<TimeParser> timeParsers, out DateTime? result)
Parameters
Type | Name | Description |
---|---|---|
System.String | mappedText | The text that was entered by the user. |
ITimeFormat | timeFormat | The TimeFormat instance used to supply formats. |
System.Collections.Generic.IEnumerable<TimeParser> | timeParsers | The time parsers. |
System.Nullable<System.DateTime> | result | A DateTime with a correctly set time part. |
Returns
Type | Description |
---|---|
System.Boolean | True, if the time was parsed correctly, false if the time was not parsed. |
Remarks
The date part of the DateTime is irrelevant and will be overwritten by the current date.