xtd 1.0.0
Loading...
Searching...
No Matches
time_zone_info.hpp
Go to the documentation of this file.
1
4#pragma once
6#include "day_of_week.hpp"
7#include "icomparable.hpp"
8#include "iequatable.hpp"
9#include "date_time.hpp"
10#include "object.hpp"
11#include "ticks.hpp"
12#include "string.hpp"
13
15namespace xtd {
38 class core_export_ time_zone_info : public xtd::icomparable<time_zone_info>, public xtd::iequatable<time_zone_info>, public xtd::object {
39 public:
41
66 class transition_time : public xtd::iequatable<transition_time>, public xtd::object {
67 public:
69 transition_time() = default;
70 transition_time(const transition_time&) = default;
72 auto operator =(const transition_time&) -> transition_time& = default;
74
76
83 [[nodiscard]] auto day() const noexcept -> xtd::uint32;
84
89 [[nodiscard]] auto day_of_week() const noexcept -> xtd::day_of_week;
90
102 [[nodiscard]] auto is_fixed_rule() const noexcept -> bool;
103
108 [[nodiscard]] auto month() const noexcept -> xtd::uint32;
109
115 [[nodiscard]] auto time_of_day() const noexcept -> xtd::date_time;
116
129 [[nodiscard]] auto week() const noexcept -> xtd::uint32;
131
133
145
157
161 [[nodiscard]] auto equals(const xtd::object& obj) const noexcept -> bool override;
165 [[nodiscard]] auto equals(const transition_time& tt) const noexcept -> bool override;
166
169 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::usize override;
171
172 private:
173 xtd::uint32 day_ = 0;
174 xtd::day_of_week day_of_week_ = xtd::day_of_week::sunday;
175 bool is_fixed_date_rule_ = true;
176 xtd::uint32 month_ = 0;
177 xtd::date_time time_of_day_;
178 xtd::uint32 week_ = 0;
179 };
180
197 class adjustment_rule : public xtd::iequatable<adjustment_rule>, public xtd::object {
198 public:
200 adjustment_rule() = default;
201 adjustment_rule(const adjustment_rule&) = default;
202 adjustment_rule(adjustment_rule&&) = default;
203 auto operator =(const adjustment_rule&) -> adjustment_rule& = default;
205
207
214 [[nodiscard]] auto date_end() const noexcept -> const xtd::date_time&;
215
221 [[nodiscard]] auto date_start() const noexcept -> const xtd::date_time&;
222
232 [[nodiscard]] auto daylight_delta() const noexcept -> xtd::time_span;
233
237 [[nodiscard]] auto daylight_transition_end() const noexcept -> transition_time;
238
242 [[nodiscard]] auto daylight_transition_start() const noexcept -> transition_time;
244
246
251 [[nodiscard]] auto equals(const xtd::object& obj) const noexcept -> bool override;
255 [[nodiscard]] auto equals(const adjustment_rule& ar) const noexcept -> bool override;
256
259 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::usize override;
261
262 private:
265 xtd::ticks daylight_delta_ {0};
266 transition_time daylight_transition_end_;
267 transition_time daylight_transition_start_;
268 };
269
270
272 time_zone_info() = default;
273 time_zone_info(const xtd::string& id, const xtd::ticks& base_utc_offset, const xtd::string& daylight_name, const xtd::string& display_name, const xtd::string& standard_name, bool supports_daylight_saving_time);
274 time_zone_info(const time_zone_info&) = default;
275 time_zone_info(time_zone_info&&) = default;
276 auto operator =(const time_zone_info&) -> time_zone_info& = default;
278
280
290 [[nodiscard]] auto base_utc_offset() const noexcept -> xtd::ticks;
291
298 [[nodiscard]] auto daylight_name() const noexcept -> const xtd::string&;
299
310 [[nodiscard]] auto display_name() const noexcept -> const xtd::string&;
311
315 [[nodiscard]] auto id() const noexcept -> const xtd::string&;
316
322 [[nodiscard]] auto standard_name() const noexcept -> const xtd::string&;
323
327 [[nodiscard]] auto supports_daylight_saving_time() const noexcept -> bool;
329
331
335 [[nodiscard]] static auto local() noexcept -> const time_zone_info&;
336
339 [[nodiscard]] static auto utc() noexcept -> const time_zone_info&;
341
343
345 [[nodiscard]] auto compare_to(const time_zone_info& tzi) const noexcept -> xtd::int32 override;
346
350 [[nodiscard]] auto equals(const xtd::object& obj) const noexcept -> bool override;
354 [[nodiscard]] auto equals(const time_zone_info& tzi) const noexcept -> bool override;
355
358 [[nodiscard]] auto get_adjustment_rules() const noexcept -> xtd::array<adjustment_rule>;
359
362 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::usize override;
363
367 [[nodiscard]] auto is_daylight_saving_time(const xtd::date_time& date_time) const noexcept -> bool;
368
369 [[nodiscard]] auto to_string() const noexcept -> xtd::string override;
371
373
379 [[nodiscard]] static auto convert_time_to_utc(const xtd::date_time& date_time) -> xtd::date_time;
380
383 [[nodiscard]] static auto get_system_time_zones() noexcept -> const xtd::collections::generic::list<time_zone_info>&;
384
390 [[nodiscard]] static auto convert_time(const xtd::date_time& date_time, const xtd::time_zone_info& destination_time_zone) -> xtd::date_time;
397 [[nodiscard]] static auto convert_time(const xtd::date_time& date_time, const xtd::time_zone_info& source_time_zone, const xtd::time_zone_info& destination_time_zone) -> xtd::date_time;
398
403 [[nodiscard]] static auto convert_time_by_system_time_zone_id(const xtd::date_time& date_time, const xtd::string& destination_time_zone_id) -> xtd::date_time;
409 [[nodiscard]] static auto 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) -> xtd::date_time;
410
415 [[nodiscard]] static auto convert_from_utc(const xtd::date_time& date_time, const xtd::time_zone_info& destination_time_zone) -> xtd::date_time;
416
421 [[nodiscard]] static auto convert_to_utc(const xtd::date_time& date_time, const xtd::time_zone_info& source_time_zone) -> xtd::date_time;
425 [[nodiscard]] static auto convert_to_utc(const xtd::date_time& date_time) -> xtd::date_time;
426
431 [[nodiscard]] static auto time_find_system_time_zone_by_id(const string& id) -> time_zone_info;
433
434 private:
435 string id_;
436 ticks base_utc_offset_;
437 string daylight_name_;
438 string display_name_;
439 string standard_name_;
440 bool supports_daylight_saving_time_ = false;
441 xtd::collections::generic::list<adjustment_rule> adjustment_rules_;
442 };
443}
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Represents an instant in time, typically expressed as a date and time of day.
Definition date_time.hpp:83
static const date_time min_value
Represents the smallest possible value of xtd::date_time. This field is read-only.
Definition date_time.hpp:105
static const date_time max_value
Represents the largest possible value of xtd::date_time. This field is read-only.
Definition date_time.hpp:95
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.hpp:22
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
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:197
auto date_start() const noexcept -> const xtd::date_time &
Gets the date when the adjustment rule takes effect.
auto equals(const xtd::object &obj) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
auto date_end() const noexcept -> const xtd::date_time &
Gets the date when the adjustment rule ceases to be in effect.
auto daylight_transition_start() const noexcept -> transition_time
Gets information about the annual transition from standard time to daylight saving time.
auto daylight_transition_end() const noexcept -> transition_time
Gets information about the annual transition from daylight saving time back to standard time.
auto get_hash_code() const noexcept -> xtd::usize override
Serves as a hash function for a particular type.
auto daylight_delta() const noexcept -> xtd::time_span
Gets the amount of time that is required to form the time zone's daylight saving time....
Provides information about a specific time change, such as the change from daylight saving time to st...
Definition time_zone_info.hpp:66
auto get_hash_code() const noexcept -> xtd::usize override
Serves as a hash function for a particular type.
auto is_fixed_rule() const noexcept -> bool
Gets a value indicating whether the time change occurs at a fixed date and time (such as November 1) ...
auto time_of_day() const noexcept -> xtd::date_time
Gets the hour, minute, and second at which the time change occurs.
auto month() const noexcept -> xtd::uint32
Gets the month in which the time change occurs.
auto equals(const xtd::object &obj) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
static auto create_floating_date_rule(xtd::date_time time_of_day, xtd::uint32 month, xtd::uint32 week, xtd::day_of_week day_of_week) -> transition_time
Defines a time change that uses a floating-date rule (that is, a time change that occurs on a specifi...
auto week() const noexcept -> xtd::uint32
Gets the week of the month in which a time change occurs.
auto day_of_week() const noexcept -> xtd::day_of_week
Gets the day of the week on which the time change occurs.
static auto create_fixed_date_rule(xtd::date_time time_of_day, xtd::uint32 month, xtd::uint32 day) -> transition_time
Defines a time change that uses a fixed-date rule (that is, a time change that occurs on a specific d...
auto day() const noexcept -> xtd::uint32
Gets the day on which the time change occurs.
Represents any time zone in the world.
Definition time_zone_info.hpp:38
static auto convert_from_utc(const xtd::date_time &date_time, const xtd::time_zone_info &destination_time_zone) -> xtd::date_time
Converts a Coordinated Universal Time (UTC) to the time in a specified time zone.
auto daylight_name() const noexcept -> const xtd::string &
Gets the display name for the current time zone's daylight saving time.
static auto utc() noexcept -> const time_zone_info &
Gets a time_zone_info object that represents the Coordinated Universal Time (UTC) zone.
static auto get_system_time_zones() noexcept -> const xtd::collections::generic::list< time_zone_info > &
Returns a sorted collection of all the time zones about which information is available on the local s...
auto to_string() const noexcept -> xtd::string override
Returns a xtd::string that represents the current object.
auto base_utc_offset() const noexcept -> xtd::ticks
Gets the time difference between the current time zone's standard time and Coordinated Universal Time...
auto supports_daylight_saving_time() const noexcept -> bool
Gets a value indicating whether the time zone has any daylight saving time rules.*.
auto get_adjustment_rules() const noexcept -> xtd::array< adjustment_rule >
Retrieves an array of xtd::time_zone_info::adjustment_rule objects that apply to the current xtd::tim...
auto compare_to(const time_zone_info &tzi) const noexcept -> xtd::int32 override
Compares the current instance with another object of the same type.
static auto convert_time_by_system_time_zone_id(const xtd::date_time &date_time, const xtd::string &destination_time_zone_id) -> xtd::date_time
Converts a time to the time in another time zone based on the time zone's identifier.
static auto local() noexcept -> const time_zone_info &
Gets a time_zone_info object that represents the local time zone.
static auto convert_to_utc(const xtd::date_time &date_time, const xtd::time_zone_info &source_time_zone) -> xtd::date_time
Converts the time in a specified time zone to Coordinated Universal Time (UTC).
auto standard_name() const noexcept -> const xtd::string &
Gets the display name for the time zone's standard time.
static auto convert_time_to_utc(const xtd::date_time &date_time) -> xtd::date_time
Converts the specified date and time to Coordinated Universal Time (UTC).
static auto time_find_system_time_zone_by_id(const string &id) -> time_zone_info
Retrieves a time_zone_info object from the registry based on its identifier.
static auto convert_time(const xtd::date_time &date_time, const xtd::time_zone_info &destination_time_zone) -> xtd::date_time
Converts a time to the time in a particular time zone.
auto equals(const xtd::object &obj) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
auto is_daylight_saving_time(const xtd::date_time &date_time) const noexcept -> bool
Indicates whether a specified date and time falls in the range of daylight saving time for the time z...
auto get_hash_code() const noexcept -> xtd::usize override
Serves as a hash function for a particular type.
auto display_name() const noexcept -> const xtd::string &
Gets the general display name that represents the time zone.
Contains xtd::date_time class.
Contains xtd::day_of_week enum class.
#define core_export_
Define shared library export.
Definition core_export.hpp:13
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
std::uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.hpp:23
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
std::chrono::duration< int64, tick > ticks
Represents a tick duration.
Definition ticks.hpp:21
Contains xtd::icomparable interface.
Contains xtd::iequatable interface.
Contains xtd::collections::generic::list <type_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.