12 class CurrentTimeZoneImpl :
public TimeZone {
14 String GetDaylightName()
const override {
17 TIME_ZONE_INFORMATION tzi;
18 if (GetTimeZoneInformation(&tzi) != TIME_ZONE_ID_INVALID) {
27 String GetStandardName()
const override {
30 TIME_ZONE_INFORMATION tzi;
31 if (GetTimeZoneInformation(&tzi) != TIME_ZONE_ID_INVALID) {
40 DaylightTime GetDaylightChanges(
int year)
override {
43 TIME_ZONE_INFORMATION tzi;
44 if (GetTimeZoneInformation(&tzi) != TIME_ZONE_ID_INVALID) {
51 TimeSpan GetUtcOffset(
const DateTimeOffset& time)
override {
54 TIME_ZONE_INFORMATION tzi;
55 DWORD result = GetTimeZoneInformation(&tzi);
56 if (result != TIME_ZONE_ID_INVALID) {
57 long totalBias = tzi.Bias;
58 if (result == TIME_ZONE_ID_DAYLIGHT) {
59 totalBias += tzi.DaylightBias;
61 else if (result == TIME_ZONE_ID_STANDARD) {
62 totalBias += tzi.StandardBias;
64 return TimeSpan(totalBias * -600000000LL);
73 static CurrentTimeZoneImpl instance;
80 TIME_ZONE_INFORMATION tzi;
81 DWORD result = GetTimeZoneInformation(&tzi);
82 return result == TIME_ZONE_ID_DAYLIGHT;
101 if (daylightTimes.
GetStart() == daylightTimes.
GetEnd())
return false;
103 return time >= daylightTimes.
GetStart() && time < daylightTimes.
GetEnd();
Represents a point in time, typically expressed as a date and time of day, relative to Coordinated Un...
int64_t GetTicks() const
Gets the number of ticks that represent the date and time of the current DateTimeOffset object in UTC...
DateTimeOffset()
Initializes a new instance of DateTimeOffset to 0 ticks.
Defines the period of daylight saving time for a region.
TimeSpan GetDelta() const
Gets the time interval that represents the difference between standard time and daylight saving time.
DaylightTime(DateTimeOffset start, DateTimeOffset end, TimeSpan delta)
Initializes a new instance of the DaylightTime class with specified start, end, and time delta.
DateTimeOffset GetEnd() const
Gets the date and time when the daylight saving period ends.
DateTimeOffset GetStart() const
Gets the date and time when the daylight saving period begins.
String()
Initializes a new instance of the String class to an empty string.
TimeSpan()
Initializes a new instance of TimeSpan to zero duration.
int64_t GetTicks() const
Gets the number of ticks that represent the value of the current TimeSpan structure.
Represents a time zone and handles time zone conversions.
static TimeZone * GetCurrentTimeZone()
Gets the time zone of the current computer.
virtual DateTimeOffset ToLocalTime(const DateTimeOffset &time)
Returns the local time that corresponds to a specified date and time value.
virtual DateTimeOffset ToUniversalTime(const DateTimeOffset &time)
Returns the Coordinated Universal Time (UTC) that corresponds to a specified time.
virtual TimeSpan GetUtcOffset(const DateTimeOffset &time)=0
Returns the Coordinated Universal Time (UTC) offset for the specified time.
virtual bool IsDaylightSavingTime(const DateTimeOffset &time)
Returns a value indicating whether the specified date and time is within a daylight saving time perio...
std::string WCharToUtf8(const wchar_t *pWStr)