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 "../IOData/datatypes.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_int64 ticks);
00066
00068 static CL_DateTime get_utc_time_from_ticks(cl_int64 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 unsigned char get_month() const;
00080 unsigned char get_day() const;
00081 unsigned char get_hour() const;
00082 unsigned char get_minutes() const;
00083 unsigned char get_seconds() const;
00084 unsigned int get_nanoseconds() const;
00085 TimeZone get_timezone() const;
00086
00090 unsigned int get_day_of_week() const;
00092
00095 public:
00096 void set_null();
00097 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);
00098 void set_year(int year);
00099 void set_month(int month);
00100 void set_day(int day);
00101 void set_hour(int hour);
00102 void set_minutes(int minutes);
00103 void set_seconds(int seconds);
00104 void set_nanoseconds(int nanoseconds);
00105 void set_timezone(TimeZone timezone);
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 CL_DateTime to_utc() const;
00116 CL_DateTime to_local() const;
00117
00119 cl_int64 to_ticks() const;
00120
00122 CL_String to_long_date_string() const;
00123
00125 CL_String to_short_date_string() const;
00126
00128 CL_String to_short_datetime_string() const;
00129
00131 CL_String to_long_time_string() const;
00132
00134 CL_String to_short_time_string() const;
00135
00137 CL_String to_string() const;
00138
00139 bool operator <(const CL_DateTime &other) const;
00140 bool operator <=(const CL_DateTime &other) const;
00141 bool operator >(const CL_DateTime &other) const;
00142 bool operator >=(const CL_DateTime &other) const;
00143 bool operator ==(const CL_DateTime &other) const;
00144 bool operator !=(const CL_DateTime &other) const;
00146
00149 private:
00150 void throw_if_invalid_date(int year, int month, int day, int hour, int minute, int seconds, int nanoseconds) const;
00151 void throw_if_null() const;
00152
00153 unsigned short year;
00154 unsigned char month;
00155 unsigned char day;
00156 unsigned char hour;
00157 unsigned char minute;
00158 unsigned char seconds;
00159 unsigned int nanoseconds;
00160
00161 TimeZone timezone;
00162 static const cl_int64 ticks_from_1601_to_1900;
00164 };