Class DateTimeToken
A Token which represents a date or time expression.
Implements
Inherited Members
Namespace: SdlSdl.LanguagePlatformCoreTokenization
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
[DataContract]
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 |
---|---|---|
string | text | The text to assign to the token |
DateTime | dateTime | The 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 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
[DataMember]
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
[DataMember]
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 |
---|---|
bool |
IsPlaceable
IsPlaceable. Always true
for this class.
Declaration
public override bool IsPlaceable { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
IsSubstitutable
IsSubstitutable. Always true
for this class.
Declaration
public override bool IsSubstitutable { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
IsTimeToken
Gets a value to indicate whether this token represents a time or not.
Declaration
public bool IsTimeToken { get; }
Property Value
Type | Description |
---|---|
bool |
Value
Gets or sets the value
Declaration
[DataMember]
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()
Creates a new instance that is a deep copy of this instance.
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 |
---|---|---|
object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to the current object; otherwise, false. |
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int |
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 |
---|---|
bool |
Localize(CultureInfo, AutoLocalizationSettings, ILocalizableToken, bool)
Declaration
public bool Localize(CultureInfo culture, AutoLocalizationSettings autoLocalizationSettings, ILocalizableToken originalMemoryToken, bool adjustCasing)
Parameters
Type | Name | Description |
---|---|---|
CultureInfo | culture | |
AutoLocalizationSettings | autoLocalizationSettings | |
ILocalizableToken | originalMemoryToken | |
bool | adjustCasing |
Returns
Type | Description |
---|---|
bool |
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 |
---|---|
Taskbool |
|
LocalizeAsync(CultureInfo, AutoLocalizationSettings, ILocalizableToken, bool, 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. |
bool | 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 |
---|---|
Taskbool |
|
SetValue(Token, bool)
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 |
bool | keepNumericSeparators | Applicable to numeric (number and measurement) tokens only: if true, do not override the original group and decimal separators. |
Returns
Type | Description |
---|---|
bool | A flag indicating whether the token's value or type were changed. |