Class DateTimeToken
A Token which represents a date or time expression.
Implements
Inherited Members
Namespace: Sdl.LanguagePlatform.Core.Tokenization
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
public class DateTimeToken : Token, ILocalizableTokenConstructors
DateTimeToken()
Initializes a new instance with default values.
Declaration
public DateTimeToken()DateTimeToken(DateTimeToken)
Initializes a new instance with the values of another token, creating a deep copy.
Declaration
public DateTimeToken(DateTimeToken other)Parameters
| Type | Name | Description | 
|---|---|---|
| DateTimeToken | other | The other token (must not be null) | 
DateTimeToken(String, DateTime, DateTimePatternType)
Initializes a new instance with the specified values.
Declaration
public DateTimeToken(string text, DateTime dateTime, DateTimePatternType type)Parameters
| Type | Name | Description | 
|---|---|---|
| String | text | The text to assign to the token | 
| DateTime | dateTime | The System.DateTime object to assign to the token's value | 
| DateTimePatternType | type | The type of the date or time token | 
DateTimeToken(String, DateTime, DateTimePatternType, String)
Initializes a new instance with the specified values.
Declaration
public DateTimeToken(string text, DateTime dateTime, DateTimePatternType type, string formatString)Parameters
| Type | Name | Description | 
|---|---|---|
| String | text | The text to assign to the token | 
| DateTime | dateTime | The System.DateTime object to assign to the token's value | 
| DateTimePatternType | type | The type of the date or time token | 
| String | formatString | The format string describing this value, used to generate new values in the same format | 
Properties
DateTimePatternType
Gets or sets the pattern type
Declaration
public DateTimePatternType DateTimePatternType { get; set; }Property Value
| Type | Description | 
|---|---|
| DateTimePatternType | 
FormatString
Gets or sets the format string corresponding to the text representation of this date value, if available. See https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings
Declaration
public string FormatString { get; set; }Property Value
| Type | Description | 
|---|---|
| String | 
IsDateToken
Gets a value to indicate whether this token represents a date or not.
Declaration
public bool IsDateToken { get; }Property Value
| Type | Description | 
|---|---|
| Boolean | 
IsPlaceable
IsPlaceable. Always true for this class.
Declaration
public override bool IsPlaceable { get; }Property Value
| Type | Description | 
|---|---|
| Boolean | 
Overrides
IsSubstitutable
IsSubstitutable. Always true for this class.
Declaration
public override bool IsSubstitutable { get; }Property Value
| Type | Description | 
|---|---|
| Boolean | 
Overrides
IsTimeToken
Gets a value to indicate whether this token represents a time or not.
Declaration
public bool IsTimeToken { get; }Property Value
| Type | Description | 
|---|---|
| Boolean | 
Value
Gets or sets the value
Declaration
public DateTime Value { get; set; }Property Value
| Type | Description | 
|---|---|
| DateTime | 
Methods
AcceptSegmentElementVisitor(ISegmentElementVisitor)
Visitor pattern implementation. Calls VisitDateTimeToken(DateTimeToken).
Declaration
public override void AcceptSegmentElementVisitor(ISegmentElementVisitor visitor)Parameters
| Type | Name | Description | 
|---|---|---|
| ISegmentElementVisitor | visitor | The visitor instance | 
Overrides
Duplicate()
See Duplicate()
Declaration
public override SegmentElement Duplicate()Returns
| Type | Description | 
|---|---|
| SegmentElement | A new instance that is a deep copy of this instance. | 
Overrides
Equals(Object)
System.Object.Equals(object)
Declaration
public override bool Equals(object obj)Parameters
| Type | Name | Description | 
|---|---|---|
| Object | obj | The object to compare with the current object. | 
Returns
| Type | Description | 
|---|---|
| Boolean | true if the specified object is equal to the current object; otherwise, false. | 
Overrides
GetHashCode()
System.Object.GetHashCode(object)
Declaration
public override int GetHashCode()Returns
| Type | Description | 
|---|---|
| Int32 | 
Overrides
GetTokenType()
Declaration
protected override TokenType GetTokenType()Returns
| Type | Description | 
|---|---|
| TokenType | 
Overrides
Localize(CultureInfo, AutoLocalizationSettings)
Declaration
public bool Localize(CultureInfo culture, AutoLocalizationSettings autoLocalizationSettings)Parameters
| Type | Name | Description | 
|---|---|---|
| CultureInfo | culture | |
| AutoLocalizationSettings | autoLocalizationSettings | 
Returns
| Type | Description | 
|---|---|
| Boolean | 
Localize(CultureInfo, AutoLocalizationSettings, ILocalizableToken, Boolean)
Declaration
public bool Localize(CultureInfo culture, AutoLocalizationSettings autoLocalizationSettings, ILocalizableToken originalMemoryToken, bool adjustCasing)Parameters
| Type | Name | Description | 
|---|---|---|
| CultureInfo | culture | |
| AutoLocalizationSettings | autoLocalizationSettings | |
| ILocalizableToken | originalMemoryToken | |
| Boolean | adjustCasing | 
Returns
| Type | Description | 
|---|---|
| Boolean | 
LocalizeAsync(CultureInfo, AutoLocalizationSettings, ICultureMetadataManager)
Auto-localizes the token according to the settings of the specified target culture and the provided auto-localization settings. The text of the token will be changed, but not the values.
For some token types, special AutoLocalizationSettings will be used, if provided.
Declaration
public virtual Task<bool> LocalizeAsync(CultureInfo culture, AutoLocalizationSettings autoLocalizationSettings, ICultureMetadataManager cultureMetadataManager)Parameters
| Type | Name | Description | 
|---|---|---|
| CultureInfo | culture | The target culture | 
| AutoLocalizationSettings | autoLocalizationSettings | Contains the AutoLocalizationSettings to use for some token types. May be null, in which case default settings will be used. | 
| ICultureMetadataManager | cultureMetadataManager | 
Returns
| Type | Description | 
|---|---|
| Task<Boolean> | 
 | 
LocalizeAsync(CultureInfo, AutoLocalizationSettings, ILocalizableToken, Boolean, ICultureMetadataManager)
Auto-localizes the token according to the settings of the specified target culture and the provided auto-localization settings. The text of the token will be changed, but not the values.
For some token types, special AutoLocalizationSettings will be used, if provided.
Declaration
public virtual Task<bool> LocalizeAsync(CultureInfo culture, AutoLocalizationSettings autoLocalizationSettings, ILocalizableToken originalMemoryToken, bool adjustCasing, ICultureMetadataManager cultureMetadataManager)Parameters
| Type | Name | Description | 
|---|---|---|
| CultureInfo | culture | The target culture | 
| AutoLocalizationSettings | autoLocalizationSettings | Contains the AutoLocalizationSettings to use for some token types. May be null, in which case default settings will be used. | 
| ILocalizableToken | originalMemoryToken | The original memory token. Some auto-localization settings will be derived from the token, if provided. | 
| Boolean | adjustCasing | If true, it is assumed that the token is in segment-initial position. Then, casing will be adjusted if the original memory token is supplied as well. | 
| ICultureMetadataManager | cultureMetadataManager | 
Returns
| Type | Description | 
|---|---|
| Task<Boolean> | 
 | 
SetValue(Token, Boolean)
Overwrites the current token's value with the value from blueprint, which
also must be a DateTimeToken. Note that only the value and the type are
overwritten, not the textual representation.
Declaration
public virtual bool SetValue(Token blueprint, bool keepNumericSeparators)Parameters
| Type | Name | Description | 
|---|---|---|
| Token | blueprint | The token to take the value from | 
| Boolean | keepNumericSeparators | (ignored) | 
Returns
| Type | Description | 
|---|---|
| Boolean | A flag indicating whether the token's value or type were changed. |