4#include <system/object.h>
5#include <system/date_time.h>
6#include <system/date_time_offset.h>
7#include <system/timespan.h>
8#include <system/iequatable.h>
9#include <system/collections/read_only_collection.h>
10#include <system/default.h>
11#include <system/details/icu_namespace.h>
12#include <system/details/lazy.h>
15ASPOSECPP_3RD_PARTY_ICU_NAMESPACE_START{
17 ASPOSECPP_3RD_PARTY_CLASS(BasicTimeZone);
53 return static_cast<int>(m_month);
59 return static_cast<int>(m_week);
65 return static_cast<int>(m_day);
71 return static_cast<DayOfWeek>(m_day_of_week);
78 return m_is_fixed_date_rule;
99 return TransitionTime(time_of_day, month, week, 1, day_of_week,
false);
112 return TransitionTime(time_of_day, month, week, day, day_of_week, is_fixed_date_rule);
117 return m_is_fixed_date_rule == other.m_is_fixed_date_rule
118 && m_time_of_day == other.m_time_of_day
119 && m_month == other.m_month
120 && (m_is_fixed_date_rule
121 ? m_day == other.m_day
122 : m_week == other.m_week && m_day_of_week == other.m_day_of_week);
140 uint8_t m_day_of_week;
142 bool m_is_fixed_date_rule;
148 static void VerifyTransitionTime(
DateTime time_of_day,
int month,
int week,
int day,
DayOfWeek day_of_week);
151 class AdjustmentRule;
176 return m_daylight_delta;
181 return m_daylight_transition_start;
186 return m_daylight_transition_end;
192 return m_base_utc_offset_delta;
228 bool no_daylight_transitions);
247 bool m_no_daylight_transitions;
252 TimeSpan base_utc_offset_delta,
bool no_daylight_transitions);
253 MEMBER_FUNCTION_MAKE_OBJECT(
261 const TimeSpan& base_utc_offset_delta,
262 bool no_daylight_transitions
268 daylight_transition_start,
269 daylight_transition_end,
270 base_utc_offset_delta,
271 no_daylight_transitions
484 const String& display_name,
485 const String& standard_display_name,
486 const String& daylight_display_name,
488 bool disable_daylight_saving_time,
489 std::unique_ptr<const codeporting_icu::BasicTimeZone>&& icu_time_zone,
491 MEMBER_FUNCTION_MAKE_OBJECT(
496 const String& display_name,
497 const String& standard_display_name,
498 const String& daylight_display_name,
500 bool disable_daylight_saving_time,
501 std::unique_ptr<const codeporting_icu::BasicTimeZone>&& icu_time_zone,
508 standard_display_name,
509 daylight_display_name,
511 disable_daylight_saving_time,
512 std::forward<std::unique_ptr<const codeporting_icu::BasicTimeZone>&&>(icu_time_zone),
Represents a specific date and time value on the time continuum. This type should be allocated on sta...
Definition: date_time.h:50
Contains the date and time of day relative to Coordinated Universal Time. Objects of this class shoul...
Definition: date_time_offset.h:16
Defines a method that determines the equality of two objects. Objects of this class should only be al...
Definition: iequatable.h:16
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
Represents a time interval. This type should be allocated on stack and passed to functions by value o...
Definition: timespan.h:59
Provides information about a time zone adjustment. Objects of this class should only be allocated usi...
Definition: timezone_info.h:161
DateTime get_DateStart() const
Returns a DateTime object that represents the date and time when the adjustment rule comes into effec...
Definition: timezone_info.h:164
bool get_HasDaylightSaving() const
FOR INTERNAL USE.
static AdjustmentRulePtr CreateAdjustmentRule(DateTime date_start, DateTime date_end, TimeSpan daylight_delta, const TransitionTime &daylight_transition_start, const TransitionTime &daylight_transition_end, TimeSpan base_utc_offset_delta, bool no_daylight_transitions)
Constructs an instance of AdjustmentRule class that represents a time adjustment rule described with ...
TimeSpan get_DaylightDelta() const
Returns in TimeSpan object that represents the amount of time required to form the daylight saving ti...
Definition: timezone_info.h:174
TimeSpan get_BaseUtcOffsetDelta() const
Returns a delta from the default UTC offset.
Definition: timezone_info.h:190
TransitionTime get_DaylightTransitionStart() const
Returns the information about transition from daylight saving time to standard time.
Definition: timezone_info.h:179
static AdjustmentRulePtr CreateAdjustmentRule(DateTime date_start, DateTime date_end, TimeSpan daylight_delta, const TransitionTime &daylight_transition_start, const TransitionTime &daylight_transition_end)
Constructs an instance of AdjustmentRule class that represents a time adjustment rule described with ...
int GetHashCode() const override
Analog of C# Object.GetHashCode() method. Enables hashing of custom objects.
TransitionTime get_DaylightTransitionEnd() const
Returns the information about transition from standard time to daylight saving time.
Definition: timezone_info.h:184
DateTime get_DateEnd() const
Returns a DateTime object that represents the date and time when the adjustment rule stops being effe...
Definition: timezone_info.h:169
bool Equals(AdjustmentRulePtr other) override
RTTI information.
Definition: timezone_info.h:39
int get_Week() const
Returns the ordinal number of the week of the month at which the time change occurs.
Definition: timezone_info.h:57
bool operator==(const TransitionTime &other) const
Definition: timezone_info.h:115
int get_Day() const
Returns the ordinal number of the day of week at which the time change occurs.
Definition: timezone_info.h:63
static TransitionTime CreateFloatingDateRule(DateTime time_of_day, int month, int week, DayOfWeek day_of_week)
Constructs an instance of TransitionTime class that represents a floating-date rule (time change that...
Definition: timezone_info.h:97
DateTime get_TimeOfDay() const
Returns a DateTime object that represents the specific time at which the time change occurs.
Definition: timezone_info.h:45
bool operator!=(const TransitionTime &other) const
Definition: timezone_info.h:125
DayOfWeek get_DayOfWeek() const
Returns the value that represents the day of week at which the time change occurs.
Definition: timezone_info.h:69
static TransitionTime CreateTransitionTime(DateTime time_of_day, int month, int week, int day, DayOfWeek day_of_week, bool is_fixed_date_rule)
Constructs an instance of TransitionTime class that represents a time change described with the speci...
Definition: timezone_info.h:110
TransitionTime()
Default constructor. FOR INTERNAL USE.
int get_Month() const
Returns the ordinal number of the month of the year at which the time change occurs.
Definition: timezone_info.h:51
bool get_IsFixedDateRule() const
Returns the value that indicates if the time change occurs at a fixed date and time or a floating dat...
Definition: timezone_info.h:76
static TransitionTime CreateFixedDateRule(DateTime time_of_day, int month, int day)
Constructs an instance of TransitionTime class that represents a fixed-date rule (time change that oc...
Definition: timezone_info.h:86
Represents an information destribing a particular time zone. Objects of this class should only be all...
Definition: timezone_info.h:32
static DateTime ConvertTimeBySystemTimeZoneId(DateTime date_time, const String &destination_time_zone_id)
Convert time to the time in a specified time zone.
bool IsDaylightSavingTime(const DateTimeOffset &date_time_offset) const
Checks if specified date and time falls in range of daylight saving time.
static DateTime ConvertTimeToUtc(DateTime date_time, const TimeZoneInfoPtr &source_time_zone)
Converts time to UTC-time.
ArrayPtr< TimeSpan > GetAmbiguousTimeOffsets(DateTime date_time) const
Gets UTC dates and times that a specified date and time can be mapped to.
bool IsDaylightSavingTime(DateTime date_time) const
Checks if specified date and time falls in range of daylight saving time.
bool IsDaylightSavingTimeNoThrow(DateTime date_time) const
Checks if specified date and time falls in range of daylight saving time.
static TimeZoneInfoPtr get_Local()
Returns an instance of TimeZoneInfo that represents a local time zone.
const TimeSpan m_base_utc_offset
A time interval between the current time zone's standard time and UTC time.
Definition: timezone_info.h:461
ArrayPtr< AdjustmentRulePtr > GetAdjustmentRules() const
Returns an array consisting of AdjustmentRule objects that represent adjustment rules that apply to t...
bool get_SupportsDaylightSavingTime() const
Gets flag indicating if time zone has daylight saving time rules.
TimeSpan GetUtcOffsetNoThrow(DateTime date_time) const
Calculates difference between time in this time zone and UTC time zone for a specified date and time....
String get_DaylightName() const
Gets name for the current time zone's daylight saving time.
static DateTime ConvertTimeToUtcNoThrow(DateTime date_time)
Converts time to UTC-time. FOR INTERNAL USE.
static DateTime ConvertTimeFromUtc(DateTime date_time, const TimeZoneInfoPtr &destination_time_zone)
Converts UTC-time to the time in a specified time zone.
const String m_display_name
The display name for the time zone.
Definition: timezone_info.h:455
static DateTime ConvertTime(DateTime date_time, const TimeZoneInfoPtr &source_time_zone, const TimeZoneInfoPtr &destination_time_zone)
Convert time from one time zone to another.
TimeZoneInfo(const String &id, TimeSpan base_utc_offset, const String &display_name, const String &standard_display_name, const String &daylight_display_name, const ArrayPtr< AdjustmentRulePtr > &adjustment_rules, bool disable_daylight_saving_time, std::unique_ptr< const codeporting_icu::BasicTimeZone > &&icu_time_zone, DateTimeKind time_zone_kind=DateTimeKind::Unspecified)
Constructs an instance of TimeZoneInfo.
System::Details::Lazy< ArrayPtr< AdjustmentRulePtr > > m_adjustment_rules
Adjustment rules that apply to the current time zone.
Definition: timezone_info.h:465
bool Equals(SharedPtr< Object > obj) override
bool IsInvalidTime(DateTime date_time) const
Checks if specified date and time is invalid.
static DateTimeOffset ConvertTime(const DateTimeOffset &date_time_offset, const TimeZoneInfoPtr &destination_time_zone)
Convert time to the time in a specified time zone.
static TimeZoneInfoPtr CreateCustomTimeZone(const String &id, TimeSpan base_utc_offset, const String &display_name, const String &standard_display_name)
Creates a custom time zone.
String get_Id() const
Returns the identifier of the time zone represented by the current object.
const std::unique_ptr< const codeporting_icu::BasicTimeZone > m_icu_time_zone
ICU Time zone.
Definition: timezone_info.h:467
static DateTimeOffset ConvertTimeBySystemTimeZoneId(const DateTimeOffset &date_time_offset, const String &destination_time_zone_id)
Convert time to the time in a specified time zone.
String ToString() const override
Analog of C# Object.ToString() method. Enables converting custom objects to string.
static TimeZoneInfoPtr CreateTimeZoneInfoFromIcuTimeZone(std::unique_ptr< const codeporting_icu::BasicTimeZone > &&time_zone, DateTimeKind time_zone_kind=DateTimeKind::Unspecified)
bool IsAmbiguousTime(const DateTimeOffset &date_time_offset) const
Checks if specified date and time is ambiguous and can be mapped to many UTC times.
const DateTimeKind m_time_zone_kind
Time zone kind (UTC, Local or Unspecified).
Definition: timezone_info.h:469
TimeSpan get_BaseUtcOffset() const
Returns an instance of TimeSpan that represents a time interval between the current time zone's stand...
bool IsAmbiguousTime(DateTime date_time) const
Checks if specified date and time is ambiguous and can be mapped to many UTC times.
int GetHashCode() const override
Analog of C# Object.GetHashCode() method. Enables hashing of custom objects.
TimeSpan GetUtcOffset(DateTime date_time) const
Calculates difference between time in this time zone and UTC time zone for a specified date and time.
TimeSpan GetUtcOffset(const DateTimeOffset &date_time_offset) const
Calculates difference between time in this time zone and UTC time zone for a specified date and time.
const String m_id
The identifier of the time zone.
Definition: timezone_info.h:453
~TimeZoneInfo() override
Destructor.
const ArrayPtr< AdjustmentRulePtr > & AdjustmentRules() const
static TimeZoneInfoPtr FindSystemTimeZoneById(const String &id)
Gets time zone with specified identifier.
static DateTime ConvertTimeToUtc(DateTime date_time)
Converts time to UTC-time.
SharedPtr< AdjustmentRule > AdjustmentRulePtr
An alias for a shared pointer to an instance of AdjustmentRule class.
Definition: timezone_info.h:153
static TimeZoneInfoPtr CreateCustomTimeZone(const String &id, TimeSpan base_utc_offset, const String &display_name, const String &standard_display_name, const String &daylight_display_name, const ArrayPtr< AdjustmentRulePtr > &adjustment_rules, bool disable_daylight_saving_time)
Creates a custom time zone.
static TimeSpan GetUtcOffsetFromUtc(DateTime time, const TimeZoneInfoPtr &zone, bool &is_daylight_savings, bool &is_ambiguous_local_dst)
Internal helper function that returns the UTC offset for a UTC-datetime in a specified time zone....
static DateTime TransitionTimeToDateTime(int32_t year, const TransitionTime &transitionTime)
Helper function that converts a year and TransitionTime into a DateTime.
static SharedPtr< System::Collections::ObjectModel::ReadOnlyCollection< TimeZoneInfoPtr > > GetSystemTimeZones()
Gets sorted collection of all time zones available on the local system.
static TimeZoneInfoPtr CreateCustomTimeZone(const String &id, TimeSpan base_utc_offset, const String &display_name, const String &standard_display_name, const String &daylight_display_name, const ArrayPtr< AdjustmentRulePtr > &adjustment_rules)
Creates a custom time zone.
static void VerifyTimeZoneInfo(const String &id, TimeSpan base_utc_offset, const ArrayPtr< AdjustmentRulePtr > &adjustment_rules)
Verify time zone information.
String get_DisplayName() const
Gets name for the current time zone.
static TimeZoneInfoPtr get_Utc()
Returns an instance of TimeZoneInfo that represents a UTC time zone.
static TimeSpan GetUtcOffsetFromUtc(DateTime time, const TimeZoneInfoPtr &zone)
Internal helper function that returns the UTC offset for a UTC-datetime in a specified time zone....
const String m_daylight_display_name
The dispaly name for the daylight saving time of the time zone.
Definition: timezone_info.h:459
const String m_standard_display_name
The display name for the standard time of the time zone.
Definition: timezone_info.h:457
String get_StandardName() const
Gets name for the current time zone's standart time.
bool Equals(TimeZoneInfoPtr other) override
Determines if the the current and specified objects are equal.
bool HasSameRules(const TimeZoneInfoPtr &other) const
Checks if current and another time zones have the same adjustment rules.
static DateTime ConvertTime(DateTime date_time, const TimeZoneInfoPtr &destination_time_zone)
Convert time to the time in a specified time zone.
const bool m_supports_daylight_saving_time
Indicates whether the time zone represented by the current object assumes transition to daylight savi...
Definition: timezone_info.h:463
ArrayPtr< TimeSpan > GetAmbiguousTimeOffsets(const DateTimeOffset &date_time_offset) const
Gets UTC dates and times that a specified date and time can be mapped to.
static DateTime ConvertTimeBySystemTimeZoneId(DateTime date_time, const String &source_time_zone_id, const String &destination_time_zone_id)
Convert time to the time in a specified time zone.
static DateTime ConvertTime(DateTime date_time, const TimeZoneInfoPtr &source_time_zone, const TimeZoneInfoPtr &destination_time_zone, bool throw_on_invalid_time)
Convert time from one time zone to another.
static void ClearCachedData()
Clear cached time zone data.
Definition: db_command.h:9
DateTimeKind
Enumeration values of which represent the kinds of date and time.
Definition: date_time_kind.h:10
@ Unspecified
Unspecified kind.
SharedPtr< TimeZoneInfo > TimeZoneInfoPtr
Alias for shared pointer to an instance of TimeZoneInfo class.
Definition: timezone_info.h:24
DayOfWeek
Enumeration that represents a day of week.
Definition: day_of_week.h:11
bool operator==(ArraySegment< T > a, ArraySegment< T > b)
Definition: array_segment.h:151