Samchon Framework for CPP  1.0.0
Date.hpp
1 #pragma once
2 #include <samchon/API.hpp>
3 
4 #include <samchon/library/IOperator.hpp>
5 
6 #include <string>
7 #include <samchon/WeakString.hpp>
8 #include <chrono>
9 
10 namespace samchon
11 {
12 namespace library
13 {
37  class SAMCHON_FRAMEWORK_API Date
38  : public std::chrono::system_clock::time_point
39  {
40  private:
41  typedef std::chrono::system_clock::time_point super;
42 
43  protected:
48  static std::chrono::system_clock::time_point TP_1970;
49 
56  static auto calcSeconds(int year, int month, int date) -> long long;
57 
64  static auto calcLastDates(int year)->std::array<int, 12>;
65 
66  public:
67  /* --------------------------------------------------------------------------
68  CONSTRUCTORS
69  -------------------------------------------------------------------------- */
75  Date();
76 
83  Date(const super&);
84 
91  Date(super&&);
92 
101  Date(int year, int month, int date);
102 
109  Date(const std::string &);
110 
117  Date(const WeakString &);
118 
124  Date(long long linuxTime);
125  virtual ~Date() = default;
126 
133  void set(const std::string &);
134 
141  virtual void set(const WeakString &);
142 
151  void set(int year, int month, int date);
152 
158  void set(long long linuxTime);
159 
160  public:
161  /* --------------------------------------------------------------------------
162  SETTERS
163  -------------------------------------------------------------------------- */
176  virtual void setYear(int);
177 
190  virtual void setMonth(int);
197  virtual void setDate(int);
198 
199  //ADD METHODS
205  virtual void addYear(int);
206 
216  virtual void addMonth(int);
217 
227  virtual void addWeek(int);
228 
238  virtual void addDate(int);
239 
240  /* --------------------------------------------------------------------------
241  GETTERS
242  -------------------------------------------------------------------------- */
248  auto getYear() const -> int;
249 
255  auto getMonth() const -> int;
256 
262  auto getDate() const -> int;
263 
269  auto getDay() const -> int;
270 
271  /* --------------------------------------------------------------------------
272  EXPORTERS
273  -------------------------------------------------------------------------- */
274  protected:
280  auto toTM() const -> struct ::tm;
281 
282  public:
288  auto toLinuxTime() const -> long long;
289 
295  virtual auto toString() const->std::string;
296  };
297 };
298 };
static std::chrono::system_clock::time_point TP_1970
time_point for 1970-01-01 09:00:00
Definition: Date.hpp:48
Definition: RWMutex.hpp:4
Date (year, month, day in month)
Definition: Date.hpp:37
Top level namespace of products built from samchon.
Definition: ByteArray.hpp:7
A string class only references characeters, reference only.
Definition: WeakString.hpp:32