xtd 0.2.0
time_zone_info.hpp
Go to the documentation of this file.
1
4#pragma once
7#include "day_of_week.hpp"
8#include "icomparable.hpp"
9#include "iequatable.hpp"
10#include "date_time.hpp"
11#include "object.hpp"
12#include "ticks.hpp"
13#include "string.hpp"
14
16namespace xtd {
39 class core_export_ time_zone_info : public xtd::icomparable<time_zone_info>, public xtd::iequatable<time_zone_info>, public xtd::object {
40 public:
42
67 class transition_time : public xtd::iequatable<transition_time>, public xtd::object {
68 public:
70 transition_time() = default;
71 transition_time(const transition_time&) = default;
73 transition_time& operator =(const transition_time&) = default;
75
77
84 uint32 day() const noexcept;
85
90 xtd::day_of_week day_of_week() const noexcept;
91
103 bool is_fixed_rule() const noexcept;
104
109 uint32 month() const noexcept;
110
116 xtd::date_time time_of_day() const noexcept;
117
130 uint32 week() const noexcept;
132
134
146
158
162 bool equals(const object& obj) const noexcept override;
166 bool equals(const transition_time& tt) const noexcept override;
167
170 xtd::size get_hash_code() const noexcept override;
172
173 private:
174 uint32 day_ = 0;
175 xtd::day_of_week day_of_week_ = xtd::day_of_week::sunday;
176 bool is_fixed_date_rule_ = true;
177 uint32 month_ = 0;
178 xtd::date_time time_of_day_;
179 uint32 week_ = 0;
180 };
181
198 class adjustement_rule : public xtd::iequatable<adjustement_rule>, public xtd::object {
199 public:
201 adjustement_rule() = default;
202 adjustement_rule(const adjustement_rule&) = default;
204 adjustement_rule& operator =(const adjustement_rule&) = default;
206
208
215 const xtd::date_time& date_end() const noexcept;
216
222 const xtd::date_time& date_start() const noexcept;
223
233 xtd::time_span daylight_delta() const noexcept;
234
239
245
247
252 bool equals(const object& obj) const noexcept override;
256 bool equals(const adjustement_rule& ar) const noexcept override;
257
260 xtd::size get_hash_code() const noexcept override;
262
263 private:
266 xtd::ticks daylight_delta_ {0};
267 transition_time daylight_transition_end_;
268 transition_time daylight_transition_start_;
269 };
270
271
273 time_zone_info() = default;
274 time_zone_info(const string& id, const ticks& base_utc_offset, const string& daylight_name, const string& display_name, const string& standard_name, bool supports_daylight_saving_time);
275 time_zone_info(const time_zone_info&) = default;
276 time_zone_info(time_zone_info&&) = default;
277 time_zone_info& operator =(const time_zone_info&) = default;
279
281
291 ticks base_utc_offset() const noexcept;
292
299 const string& daylight_name() const noexcept;
300
311 const string& display_name() const noexcept;
312
316 const string& id() const noexcept;
317
323 const string& standard_name() const noexcept;
324
328 bool supports_daylight_saving_time() const noexcept;
330
332
336 static const time_zone_info& local() noexcept;
337
340 static const time_zone_info& utc() noexcept;
342
344
346 int32 compare_to(const time_zone_info& tzi) const noexcept override;
347
351 bool equals(const object& obj) const noexcept override;
355 bool equals(const time_zone_info& tzi) const noexcept override;
356
360
363 xtd::size get_hash_code() const noexcept override;
364
368 bool is_daylight_saving_time(const xtd::date_time& date_time) const noexcept;
369
370 xtd::string to_string() const noexcept override;
372
374
382
385 static const std::list<time_zone_info>& get_system_time_zones() noexcept;
386
392 static xtd::date_time convert_time(const xtd::date_time& date_time, const xtd::time_zone_info& destination_time_zone);
399 static xtd::date_time convert_time(const xtd::date_time& date_time, const xtd::time_zone_info& source_time_zone, const xtd::time_zone_info& destination_time_zone);
400
405 static xtd::date_time convert_time_by_system_time_zone_id(const xtd::date_time& date_time, const xtd::string& destination_time_zone_id);
411 static xtd::date_time convert_time_by_system_time_zone_id(const xtd::date_time& date_time, const xtd::string& source_time_zone_id, const xtd::string& destination_time_zone_id);
412
417 static xtd::date_time convert_from_utc(const xtd::date_time& date_time, const xtd::time_zone_info& destination_time_zone);
418
423 static xtd::date_time convert_to_utc(const xtd::date_time& date_time, const xtd::time_zone_info& source_time_zone);
428
436
437 private:
438 string id_;
439 ticks base_utc_offset_;
440 string daylight_name_;
441 string display_name_;
442 string standard_name_;
443 bool supports_daylight_saving_time_ = false;
444 xtd::collections::generic::list<adjustement_rule> adjustement_rules_;
445 };
446}
Contains xtd::argument_out_of_range_exception exception.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
Represents an instant in time, typically expressed as a date and time of day.
Definition date_time.hpp:85
static const date_time min_value
Represents the smallest possible value of xtd::date_time. This field is read-only.
Definition date_time.hpp:107
static const date_time max_value
Represents the largest possible value of xtd::date_time. This field is read-only.
Definition date_time.hpp:97
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.hpp:21
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
Represents a time interval.
Definition time_span.hpp:29
Provides information about a time zone adjustment, such as the transition to and from daylight saving...
Definition time_zone_info.hpp:198
bool equals(const object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
xtd::size get_hash_code() const noexcept override
Serves as a hash function for a particular type.
const xtd::date_time & date_end() const noexcept
Gets the date when the adjustment rule ceases to be in effect.
transition_time daylight_transition_end() const noexcept
Gets information about the annual transition from daylight saving time back to standard time.
transition_time daylight_transition_start() const noexcept
Gets information about the annual transition from standard time to daylight saving time.
xtd::time_span daylight_delta() const noexcept
Gets the amount of time that is required to form the time zone's daylight saving time....
const xtd::date_time & date_start() const noexcept
Gets the date when the adjustment rule takes effect.
Provides information about a specific time change, such as the change from daylight saving time to st...
Definition time_zone_info.hpp:67
xtd::size get_hash_code() const noexcept override
Serves as a hash function for a particular type.
bool is_fixed_rule() const noexcept
Gets a value indicating whether the time change occurs at a fixed date and time (such as November 1) ...
bool equals(const object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
static transition_time create_floating_date_rule(date_time time_of_day, uint32 month, uint32 week, xtd::day_of_week day_of_week)
Defines a time change that uses a floating-date rule (that is, a time change that occurs on a specifi...
uint32 month() const noexcept
Gets the month in which the time change occurs.
static transition_time create_fixed_date_rule(date_time time_of_day, uint32 month, uint32 day)
Defines a time change that uses a fixed-date rule (that is, a time change that occurs on a specific d...
xtd::date_time time_of_day() const noexcept
Gets the hour, minute, and second at which the time change occurs.
uint32 week() const noexcept
Gets the week of the month in which a time change occurs.
uint32 day() const noexcept
Gets the day on which the time change occurs.
xtd::day_of_week day_of_week() const noexcept
Gets the day of the week on which the time change occurs.
Represents any time zone in the world.
Definition time_zone_info.hpp:39
static xtd::date_time convert_to_utc(const xtd::date_time &date_time, const xtd::time_zone_info &source_time_zone)
Converts the time in a specified time zone to Coordinated Universal Time (UTC).
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
int32 compare_to(const time_zone_info &tzi) const noexcept override
Compares the current instance with another object of the same type.
static time_zone_info time_find_system_time_zone_by_id(const string &id)
Retrieves a time_zone_info object from the registry based on its identifier.
xtd::size get_hash_code() const noexcept override
Serves as a hash function for a particular type.
bool is_daylight_saving_time(const xtd::date_time &date_time) const noexcept
Indicates whether a specified date and time falls in the range of daylight saving time for the time z...
const string & daylight_name() const noexcept
Gets the display name for the current time zone's daylight saving time.
bool equals(const object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
static const time_zone_info & utc() noexcept
Gets a time_zone_info object that represents the Coordinated Universal Time (UTC) zone.
static xtd::date_time convert_time(const xtd::date_time &date_time, const xtd::time_zone_info &destination_time_zone)
Converts a time to the time in a particular time zone.
static const std::list< time_zone_info > & get_system_time_zones() noexcept
Returns a sorted collection of all the time zones about which information is available on the local s...
static xtd::date_time convert_from_utc(const xtd::date_time &date_time, const xtd::time_zone_info &destination_time_zone)
Converts a Coordinated Universal Time (UTC) to the time in a specified time zone.
const string & standard_name() const noexcept
Gets the display name for the time zone's standard time.
static xtd::date_time convert_time_to_utc(const xtd::date_time &date_time)
Converts the specified date and time to Coordinated Universal Time (UTC).
bool supports_daylight_saving_time() const noexcept
Gets a value indicating whether the time zone has any daylight saving time rules.*.
const string & display_name() const noexcept
Gets the general display name that represents the time zone.
static const time_zone_info & local() noexcept
Gets a time_zone_info object that represents the local time zone.
array< adjustement_rule > get_adjustement_rules() const noexcept
Retrieves an array of xtd::time_zone_info::adjustment_rule objects that apply to the current xtd::tim...
static xtd::date_time convert_time_by_system_time_zone_id(const xtd::date_time &date_time, const xtd::string &destination_time_zone_id)
Converts a time to the time in another time zone based on the time zone's identifier.
ticks base_utc_offset() const noexcept
Gets the time difference between the current time zone's standard time and Coordinated Universal Time...
Contains xtd::date_time class.
Contains xtd::day_of_week enum class.
#define core_export_
Define shared library export.
Definition core_export.hpp:13
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.hpp:23
std::chrono::duration< int64, tick > ticks
Represents a tick duration.
Definition ticks.hpp:21
@ sunday
Indicates sunday.
Definition day_of_week.hpp:27
Contains xtd::icomparable interface.
Contains xtd::iequatable interface.
Contains xtd::collections::generic::list <value_t> class.
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::object class.
Contains xtd::string alias.
Contains xtd::ticks typedef.