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, ILocalizableToken
Constructors
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 |
|---|---|---|
| System.String | text | The text to assign to the token |
| System.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 |
|---|---|---|
| System.String | text | The text to assign to the token |
| System.DateTime | dateTime | The System.DateTime object to assign to the token's value |
| DateTimePatternType | type | The type of the date or time token |
| System.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 |
|---|---|
| System.String |
IsDateToken
Gets a value to indicate whether this token represents a date or not.
Declaration
public bool IsDateToken { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsPlaceable
IsPlaceable. Always true for this class.
Declaration
public override bool IsPlaceable { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Overrides
IsSubstitutable
IsSubstitutable. Always true for this class.
Declaration
public override bool IsSubstitutable { get; }
Property Value
| Type | Description |
|---|---|
| System.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 |
|---|---|
| System.Boolean |
Value
Gets or sets the value
Declaration
public DateTime Value { get; set; }
Property Value
| Type | Description |
|---|---|
| System.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)
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj | The object to compare with the current object. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the specified object is equal to the current object; otherwise, false. |
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 |
Overrides
GetSimilarity(SegmentElement)
Declaration
public override SegmentElement.Similarity GetSimilarity(SegmentElement other)
Parameters
| Type | Name | Description |
|---|---|---|
| SegmentElement | other | The other instance. |
Returns
| Type | Description |
|---|---|
| SegmentElement.Similarity | A value indicating the degree of similarity to the provided segment element. |
Overrides
GetTokenType()
Declaration
protected override TokenType GetTokenType()
Returns
| Type | Description |
|---|---|
| TokenType |
Overrides
Localize(CultureInfo, AutoLocalizationSettings)
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 bool Localize(CultureInfo culture, AutoLocalizationSettings autoLocalizationSettings)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Globalization.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. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Localize(CultureInfo, AutoLocalizationSettings, ILocalizableToken, Boolean)
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 bool Localize(CultureInfo culture, AutoLocalizationSettings autoLocalizationSettings, ILocalizableToken originalMemoryToken, bool adjustCasing)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Globalization.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. |
| System.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. |
Returns
| Type | Description |
|---|---|
| System.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 |
| System.Boolean | keepNumericSeparators | (ignored) |
Returns
| Type | Description |
|---|---|
| System.Boolean | A flag indicating whether the token's value or type were changed. |