xtd 0.2.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 transition_time& operator =(const transition_time&) = default;
74
76
83 uint32 day() const noexcept;
84
89 xtd::day_of_week day_of_week() const noexcept;
90
102 bool is_fixed_rule() const noexcept;
103
108 uint32 month() const noexcept;
109
115 xtd::date_time time_of_day() const noexcept;
116
129 uint32 week() const noexcept;
131
133
144 static transition_time create_fixed_date_rule(date_time time_of_day, uint32 month, uint32 day);
145
156 static transition_time create_floating_date_rule(date_time time_of_day, uint32 month, uint32 week, xtd::day_of_week day_of_week);
157
158 using object::equals;
159 bool equals(const transition_time& tt) const noexcept override;
161
162 private:
163 uint32 day_ = 0;
164 xtd::day_of_week day_of_week_ = xtd::day_of_week::sunday;
165 bool is_fixed_date_rule_ = true;
166 uint32 month_ = 0;
167 xtd::date_time time_of_day_;
168 uint32 week_ = 0;
169 };
170
187 class adjustement_rule : public xtd::iequatable<adjustement_rule>, public xtd::object {
188 public:
190 adjustement_rule() = default;
191 adjustement_rule(const adjustement_rule&) = default;
193 adjustement_rule& operator =(const adjustement_rule&) = default;
195
197
204 const xtd::date_time& date_end() const noexcept;
205
211 const xtd::date_time& date_start() const noexcept;
212
222 xtd::time_span daylight_delta() const noexcept;
223
227 transition_time daylight_transition_end() const noexcept;
228
232 transition_time daylight_transition_start() const noexcept;
234
236
238 using object::equals;
239 bool equals(const adjustement_rule& ar) const noexcept override;
241
242 private:
243 xtd::date_time date_end_ {date_time::max_value};
244 xtd::date_time date_start_ {date_time::min_value};
245 xtd::ticks daylight_delta_ {0};
246 transition_time daylight_transition_end_;
247 transition_time daylight_transition_start_;
248 };
250
252 time_zone_info() = default;
253 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);
254 time_zone_info(const time_zone_info&) = default;
255 time_zone_info(time_zone_info&&) = default;
256 time_zone_info& operator =(const time_zone_info&) = default;
258
260
270 ticks base_utc_offset() const noexcept;
271
278 const string& daylight_name() const noexcept;
279
290 const string& display_name() const noexcept;
291
295 const string& id() const noexcept;
296
302 const string& standard_name() const noexcept;
303
307 bool supports_daylight_saving_time() const noexcept;
309
311
315 static const time_zone_info& local() noexcept;
316
319 static const time_zone_info& utc() noexcept;
321
323
325 int32 compare_to(const time_zone_info& tzi) const noexcept override;
326
327 using object::equals;
328 bool equals(const time_zone_info& tzi) const noexcept override;
329
332 std::vector<adjustement_rule> get_adjustement_rules() const noexcept;
333
337 bool is_daylight_saving_time(const xtd::date_time& date_time) const noexcept;
338
339 xtd::string to_string() const noexcept override;
341
343
350 static xtd::date_time convert_time_to_utc(const xtd::date_time& date_time);
351
354 static const std::list<time_zone_info>& get_system_time_zones() noexcept;
355
361 static xtd::date_time convert_time(const xtd::date_time& date_time, const xtd::time_zone_info& destination_time_zone);
368 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);
369
374 static xtd::date_time convert_time_by_system_time_zone_id(const xtd::date_time& date_time, const xtd::string& destination_time_zone_id);
380 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);
381
386 static xtd::date_time convert_from_utc(const xtd::date_time& date_time, const xtd::time_zone_info& destination_time_zone);
387
392 static xtd::date_time convert_to_utc(const xtd::date_time& date_time, const xtd::time_zone_info& source_time_zone);
396 static xtd::date_time convert_to_utc(const xtd::date_time& date_time);
397
403 static time_zone_info time_find_system_time_zone_by_id(const string& id);
405
406 private:
407 string id_;
408 ticks base_utc_offset_;
409 string daylight_name_;
410 string display_name_;
411 string standard_name_;
412 bool supports_daylight_saving_time_ = false;
413 std::vector<adjustement_rule> adjustement_rules_;
414 };
415}
Contains xtd::argument_out_of_range_exception exception.
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:42
Provides information about a time zone adjustment, such as the transition to and from daylight saving...
Definition time_zone_info.hpp:187
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:66
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:38
ticks base_utc_offset() const noexcept
Gets the time difference between the current time zone's standard time and Coordinated Universal Time...
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
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.
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.
Represents a time interval.
Definition time_span.hpp:29
Contains xtd::ticks typedef.
Contains xtd::date_time class.