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
145 static transition_time create_fixed_date_rule(date_time time_of_day, uint32 month, uint32 day);
146
157 static transition_time create_floating_date_rule(date_time time_of_day, uint32 month, uint32 week, xtd::day_of_week day_of_week);
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
238 transition_time daylight_transition_end() const noexcept;
239
243 transition_time daylight_transition_start() const noexcept;
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:
264 xtd::date_time date_end_ {date_time::max_value};
265 xtd::date_time date_start_ {date_time::min_value};
266 xtd::ticks daylight_delta_ {0};
267 transition_time daylight_transition_end_;
268 transition_time daylight_transition_start_;
269 };
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
359 array<adjustement_rule> get_adjustement_rules() const noexcept;
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
381 static xtd::date_time convert_time_to_utc(const xtd::date_time& date_time);
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);
427 static xtd::date_time convert_to_utc(const xtd::date_time& date_time);
428
434 static time_zone_info time_find_system_time_zone_by_id(const string& id);
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
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:43
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
const xtd::date_time & date_end() const noexcept
Gets the date when the adjustment rule ceases to be in effect.
Provides information about a specific time change, such as the change from daylight saving time to st...
Definition time_zone_info.hpp:67
uint32 day() const noexcept
Gets the day on which the time change occurs.
Represents any time zone in the world.
Definition time_zone_info.hpp:39
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
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
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
std::chrono::duration< int64, tick > ticks
Represents a tick duration.
Definition ticks.hpp:21
day_of_week
Specifies the day of the week.
Definition day_of_week.hpp:25
Contains xtd::icomparable interface.
Contains xtd::iequatable interface.
Contains xtd::collections::generic::list <value_t> class.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Contains xtd::object class.
Contains xtd::string alias.
Contains xtd::ticks typedef.