Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00032
00033
00034 #pragma once
00035
00036 #include "../api_core.h"
00037 #include "../System/cl_platform.h"
00038
00042 class CL_API_CORE CL_DateTime
00043 {
00046 public:
00047 enum TimeZone
00048 {
00049 local_timezone,
00050 utc_timezone
00051 };
00052
00054 CL_DateTime();
00055 CL_DateTime(int year, int month, int day, int hour = 0, int minute = 0, int seconds = 0, int nanoseconds = 0, TimeZone timezone=utc_timezone);
00056 ~CL_DateTime();
00057
00059 static CL_DateTime get_current_local_time();
00060
00062 static CL_DateTime get_current_utc_time();
00063
00065 static CL_DateTime get_local_time_from_ticks(cl_byte64 ticks);
00066
00068 static CL_DateTime get_utc_time_from_ticks(cl_byte64 ticks);
00069
00070 static CL_DateTime from_short_date_string(const CL_String &value);
00071
00073
00076 public:
00077 bool is_null() const;
00078 unsigned short get_year() const;
00079
00083 unsigned char get_month() const;
00084 unsigned char get_day() const;
00085 unsigned char get_hour() const;
00086 unsigned char get_minutes() const;
00087 unsigned char get_seconds() const;
00088 unsigned int get_nanoseconds() const;
00089 TimeZone get_timezone() const;
00090
00094 unsigned int get_day_of_week() const;
00096
00099 public:
00100 void set_null();
00101 void set_date(int year, int month, int day, int hour = 0, int minute = 0, int seconds = 0, int nanoseconds = 0, TimeZone timezone = utc_timezone);
00102 void set_year(int year);
00103 void set_month(int month);
00104 void set_day(int day);
00105 void set_hour(int hour);
00106 void set_minutes(int minutes);
00107 void set_seconds(int seconds);
00108 void set_nanoseconds(int nanoseconds);
00109 void set_timezone(TimeZone timezone);
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 CL_DateTime to_utc() const;
00120 CL_DateTime to_local() const;
00121
00123 cl_byte64 to_ticks() const;
00124
00126 CL_String to_long_date_string() const;
00127
00129 CL_String to_short_date_string() const;
00130
00132 CL_String to_short_datetime_string() const;
00133
00135 CL_String to_long_time_string() const;
00136
00138 CL_String to_short_time_string() const;
00139
00141 CL_String to_string() const;
00142
00143 bool operator <(const CL_DateTime &other) const;
00144 bool operator <=(const CL_DateTime &other) const;
00145 bool operator >(const CL_DateTime &other) const;
00146 bool operator >=(const CL_DateTime &other) const;
00147 bool operator ==(const CL_DateTime &other) const;
00148 bool operator !=(const CL_DateTime &other) const;
00150
00153 private:
00154 void throw_if_invalid_date(int year, int month, int day, int hour, int minute, int seconds, int nanoseconds) const;
00155 void throw_if_null() const;
00156
00157 unsigned short year;
00158 unsigned char month;
00159 unsigned char day;
00160 unsigned char hour;
00161 unsigned char minute;
00162 unsigned char seconds;
00163 unsigned int nanoseconds;
00164
00165 TimeZone timezone;
00166 static const cl_byte64 ticks_from_1601_to_1900;
00168 };