Partager via


DateTimeStyles Enumeration

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Defines the formatting options that customize string parsing for a number of DateTime and DateTimeOffset parsing methods.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<FlagsAttribute> _
<ComVisibleAttribute(True)> _
Public Enumeration DateTimeStyles
[FlagsAttribute]
[ComVisibleAttribute(true)]
public enum DateTimeStyles

Members

Member name Description
Supported by Silverlight for Windows PhoneSupported by Xbox 360 None Default formatting options must be used. This value represents the default style for DateTime.Parse, DateTime.ParseExact, and DateTime.TryParse.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 AllowLeadingWhite Leading white-space characters must be ignored during parsing, except if they occur in the DateTimeFormatInfo format patterns.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 AllowTrailingWhite Trailing white-space characters must be ignored during parsing, except if they occur in the DateTimeFormatInfo format patterns.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 AllowInnerWhite Extra white-space characters in the middle of the string must be ignored during parsing, except if they occur in the DateTimeFormatInfo format patterns.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 AllowWhiteSpaces Extra white-space characters anywhere in the string must be ignored during parsing, except if they occur in the DateTimeFormatInfo format patterns. This value is a combination of the AllowLeadingWhite, AllowTrailingWhite, and AllowInnerWhite values.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 NoCurrentDateDefault If the parsed string contains only the time and not the date, the parsing methods assume the Gregorian date with year = 1, month = 1, and day = 1. If this value is not used, the current date is assumed.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 AdjustToUniversal Date and time are returned as a Coordinated Universal Time (UTC). If the input string denotes a local time, through a time zone specifier or AssumeLocal, the date and time are converted from the local time to UTC. If the input string denotes a UTC time, through a time zone specifier or AssumeUniversal, no conversion occurs. If the input string does not denote a local or UTC time, no conversion occurs and the resulting Kind property is Unspecified.

Cannot be used with RoundtripKind.

Supported by Silverlight for Windows PhoneSupported by Xbox 360 AssumeLocal If no time zone is specified in the parsed string, the string is assumed to denote a local time.

Cannot be used with AssumeUniversal or RoundtripKind.

Supported by Silverlight for Windows PhoneSupported by Xbox 360 AssumeUniversal If no time zone is specified in the parsed string, the string is assumed to denote a UTC.

Cannot be used with AssumeLocal or RoundtripKind.

Supported by Silverlight for Windows PhoneSupported by Xbox 360 RoundtripKind For parsing operations using DateTime methods on strings that contain time zone information, tries to prevent the conversion to a local DateTime value with its Kind property set to DateTimeKind.Local. For DateTimeOffset values, this flag has no effect.

Remarks

The DateTimeStyles enumeration is used as a parameter that controls the parsing operation of the following methods:

The ParseExact and TryParseExact methods can use any of the DateTimeStyles values. However, if none of the Allow* values is selected, the input string must have exactly the same white-space characters as the format string.

If the input string does not contain any indication of the time zone, parsing methods assume that the date and time represents the local time and either set the DateTime.Kind property to DateTimeKind.Local or set the DateTimeOffset.Offset property to the time zone offset of the local system. To convert this date and time to Coordinated Universal Time (UTC), use the AdjustToUniversal value. The same effect can be achieved using ToUniversalTime. However, using the AdjustToUniversal value is more efficient.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference