xtd 0.2.0
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
161 bool equals(const object& obj) const noexcept override;
165 bool equals(const transition_time& tt) const noexcept override;
166
169 xtd::size get_hash_code() const noexcept override;
171
172 private:
173 uint32 day_ = 0;
174 xtd::day_of_week day_of_week_ = xtd::day_of_week::sunday;
175 bool is_fixed_date_rule_ = true;
176 uint32 month_ = 0;
177 xtd::date_time time_of_day_;
178 uint32 week_ = 0;
179 };
180
197 class adjustement_rule : public xtd::iequatable<adjustement_rule>, public xtd::object {
198 public:
200 adjustement_rule() = default;
201 adjustement_rule(const adjustement_rule&) = default;
203 adjustement_rule& operator =(const adjustement_rule&) = default;
205
207
214 const xtd::date_time& date_end() const noexcept;
215
221 const xtd::date_time& date_start() const noexcept;
222
232 xtd::time_span daylight_delta() const noexcept;
233
237 transition_time daylight_transition_end() const noexcept;
238
242 transition_time daylight_transition_start() const noexcept;
244
246
251 bool equals(const object& obj) const noexcept override;
255 bool equals(const adjustement_rule& ar) const noexcept override;
256
259 xtd::size get_hash_code() const noexcept override;
261
262 private:
263 xtd::date_time date_end_ {date_time::max_value};
264 xtd::date_time date_start_ {date_time::min_value};
265 xtd::ticks daylight_delta_ {0};
266 transition_time daylight_transition_end_;
267 transition_time daylight_transition_start_;
268 };
270
272 time_zone_info() = default;
273 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);
274 time_zone_info(const time_zone_info&) = default;
275 time_zone_info(time_zone_info&&) = default;
276 time_zone_info& operator =(const time_zone_info&) = default;
278
280
290 ticks base_utc_offset() const noexcept;
291
298 const string& daylight_name() const noexcept;
299
310 const string& display_name() const noexcept;
311
315 const string& id() const noexcept;
316
322 const string& standard_name() const noexcept;
323
327 bool supports_daylight_saving_time() const noexcept;
329
331
335 static const time_zone_info& local() noexcept;
336
339 static const time_zone_info& utc() noexcept;
341
343
345 int32 compare_to(const time_zone_info& tzi) const noexcept override;
346
350 bool equals(const object& obj) const noexcept override;
354 bool equals(const time_zone_info& tzi) const noexcept override;
355
358 std::vector<adjustement_rule> get_adjustement_rules() const noexcept;
359
362 xtd::size get_hash_code() const noexcept override;
363
367 bool is_daylight_saving_time(const xtd::date_time& date_time) const noexcept;
368
369 xtd::string to_string() const noexcept override;
371
373
380 static xtd::date_time convert_time_to_utc(const xtd::date_time& date_time);
381
384 static const std::list<time_zone_info>& get_system_time_zones() noexcept;
385
391 static xtd::date_time convert_time(const xtd::date_time& date_time, const xtd::time_zone_info& destination_time_zone);
398 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);
399
404 static xtd::date_time convert_time_by_system_time_zone_id(const xtd::date_time& date_time, const xtd::string& destination_time_zone_id);
410 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);
411
416 static xtd::date_time convert_from_utc(const xtd::date_time& date_time, const xtd::time_zone_info& destination_time_zone);
417
422 static xtd::date_time convert_to_utc(const xtd::date_time& date_time, const xtd::time_zone_info& source_time_zone);
426 static xtd::date_time convert_to_utc(const xtd::date_time& date_time);
427
433 static time_zone_info time_find_system_time_zone_by_id(const string& id);
435
436 private:
437 string id_;
438 ticks base_utc_offset_;
439 string daylight_name_;
440 string display_name_;
441 string standard_name_;
442 bool supports_daylight_saving_time_ = false;
443 std::vector<adjustement_rule> adjustement_rules_;
444 };
445}
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: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:197
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::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.
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.