DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
DotNetDupe::System::TimeZone Class Referenceabstract

Represents a time zone and handles time zone conversions. More...

#include <TimeZone.h>

Inheritance diagram for DotNetDupe::System::TimeZone:

Public Member Functions

virtual DaylightTime GetDaylightChanges (int year)=0
 Returns the daylight saving time period for a particular year.
virtual String GetDaylightName () const =0
 Gets the daylight saving time zone name.
virtual String GetStandardName () const =0
 Gets the standard time zone name.
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 period.
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.
Public Member Functions inherited from DotNetDupe::System::Object
virtual ~Object ()=default
 Virtual destructor ensuring polymorphic cleanup.
virtual bool Equals (const Object &obj) const
 Determines whether the specified Object is equal to the current Object.
virtual int GetHashCode () const
 Serves as the default hash function.
bool operator== (const Object &obj) const
 Determines reference equality between two objects.
char * ToStringA () const
 Returns narrow-character string representation.
wchar_t * ToStringW () const
 Returns wide-character string representation.

Static Public Member Functions

static TimeZoneGetCurrentTimeZone ()
 Gets the time zone of the current computer.
static bool IsDaylightSavingTime (const DateTimeOffset &time, const DaylightTime &daylightTimes)
 Returns a value indicating whether the specified date and time is within the specified daylight saving time period.
Static Public Member Functions inherited from DotNetDupe::System::Object
static bool Equals (const Object &obj1, const Object &obj2)
 Static helper determining whether two object instances are equal.

Detailed Description

Represents a time zone and handles time zone conversions.

Modeled after .NET System.TimeZone. Supports querying standard and daylight names, daylight changes, UTC offset calculations, and UTC/local time conversions.

Definition at line 23 of file TimeZone.h.

Member Function Documentation

◆ GetCurrentTimeZone()

TimeZone * DotNetDupe::System::TimeZone::GetCurrentTimeZone ( )
static

Gets the time zone of the current computer.

Returns
Pointer to the local TimeZone singleton instance.

Retrieve singleton current time zone instance.

Definition at line 71 of file TimeZone.cpp.

Referenced by GetStandardName().

◆ GetDaylightChanges()

virtual DaylightTime DotNetDupe::System::TimeZone::GetDaylightChanges ( int year)
pure virtual

Returns the daylight saving time period for a particular year.

Parameters
yearThe year to evaluate.
Returns
DaylightTime structure specifying daylight start, end, and delta.

References DOTNETDUPE_API.

◆ GetDaylightName()

virtual String DotNetDupe::System::TimeZone::GetDaylightName ( ) const
pure virtual

Gets the daylight saving time zone name.

Returns
The daylight name string.

References DOTNETDUPE_API.

◆ GetStandardName()

virtual String DotNetDupe::System::TimeZone::GetStandardName ( ) const
pure virtual

Gets the standard time zone name.

Returns
The standard name string.

References DOTNETDUPE_API, and GetCurrentTimeZone().

◆ GetUtcOffset()

virtual TimeSpan DotNetDupe::System::TimeZone::GetUtcOffset ( const DateTimeOffset & time)
pure virtual

Returns the Coordinated Universal Time (UTC) offset for the specified time.

Parameters
timeThe point in time to evaluate.
Returns
A TimeSpan representing the UTC offset.

References DOTNETDUPE_API, IsDaylightSavingTime(), ToLocalTime(), and ToUniversalTime().

Referenced by ToLocalTime(), and ToUniversalTime().

◆ IsDaylightSavingTime() [1/2]

bool DotNetDupe::System::TimeZone::IsDaylightSavingTime ( const DateTimeOffset & time)
virtual

Returns a value indicating whether the specified date and time is within a daylight saving time period.

Parameters
timeThe date and time to evaluate.
Returns
True if time falls within daylight saving time; otherwise false.

Step: Check if current time falls within active daylight saving period.

Definition at line 77 of file TimeZone.cpp.

Referenced by GetUtcOffset().

◆ IsDaylightSavingTime() [2/2]

bool DotNetDupe::System::TimeZone::IsDaylightSavingTime ( const DateTimeOffset & time,
const DaylightTime & daylightTimes )
static

Returns a value indicating whether the specified date and time is within the specified daylight saving time period.

Parameters
timeA date and time value.
daylightTimesA daylight saving time period.
Returns
True if time is in daylight saving period; otherwise false.

Guard: If delta is zero or start equals end, daylight saving is not active.

Check if time falls between daylight transition start and end bounds.

Definition at line 98 of file TimeZone.cpp.

References DotNetDupe::System::DaylightTime::GetDelta(), DotNetDupe::System::DaylightTime::GetEnd(), DotNetDupe::System::DaylightTime::GetStart(), and DotNetDupe::System::TimeSpan::GetTicks().

◆ ToLocalTime()

DateTimeOffset DotNetDupe::System::TimeZone::ToLocalTime ( const DateTimeOffset & time)
virtual

Returns the local time that corresponds to a specified date and time value.

Parameters
timeA DateTimeOffset value.
Returns
Converted local DateTimeOffset.

Step: Convert UTC time to local time by adding current UTC offset.

Definition at line 88 of file TimeZone.cpp.

References DotNetDupe::System::DateTimeOffset::DateTimeOffset(), DotNetDupe::System::DateTimeOffset::GetTicks(), and GetUtcOffset().

Referenced by GetUtcOffset().

◆ ToUniversalTime()

DateTimeOffset DotNetDupe::System::TimeZone::ToUniversalTime ( const DateTimeOffset & time)
virtual

Returns the Coordinated Universal Time (UTC) that corresponds to a specified time.

Parameters
timeA DateTimeOffset value.
Returns
Converted UTC DateTimeOffset.

Step: Convert local time to universal time by subtracting current UTC offset.

Definition at line 93 of file TimeZone.cpp.

References DotNetDupe::System::DateTimeOffset::DateTimeOffset(), DotNetDupe::System::DateTimeOffset::GetTicks(), and GetUtcOffset().

Referenced by GetUtcOffset().


The documentation for this class was generated from the following files: