DateTime::DateTime(const TimeStamp &ts)
{
- init(ts);
+ add_raw(ts.raw());
}
-DateTime::DateTime(const TimeStamp &ts, const TimeZone &tz)
+DateTime::DateTime(const TimeStamp &ts, const TimeZone &tz):
+ DateTime(ts)
{
- init(ts);
convert_timezone(tz);
}
-DateTime::DateTime(int y, unsigned char m, unsigned char d)
-{
- init(y, m, d, 0, 0, 0, 0);
-}
-
-DateTime::DateTime(int y, unsigned char m, unsigned char d, unsigned char h, unsigned char n, unsigned char s)
+DateTime::DateTime(int y, unsigned char m, unsigned char d):
+ DateTime(y, m, d, 0, 0, 0, 0)
+{ }
+
+DateTime::DateTime(int y, unsigned char m, unsigned char d, unsigned char h, unsigned char n, unsigned char s):
+ DateTime(y, m, d, h, n, s, 0)
+{ }
+
+DateTime::DateTime(int y, unsigned char m, unsigned char d, unsigned char h, unsigned char n, unsigned char s, unsigned u):
+ year(y),
+ month(m),
+ mday(d),
+ hour(h),
+ minute(n),
+ second(s),
+ usec(u)
{
- init(y, m, d, h, n, s, 0);
-}
-
-DateTime::DateTime(int y, unsigned char m, unsigned char d, unsigned char h, unsigned char n, unsigned char s, unsigned u)
-{
- init(y, m, d, h, n, s, u);
-}
-
-void DateTime::init(const TimeStamp &ts)
-{
- year = 1970;
- month = 1;
- mday = 1;
- hour = 0;
- minute = 0;
- second = 0;
- usec = 0;
- add_raw(ts.raw());
-}
-
-void DateTime::init(int y, unsigned char m, unsigned char d, unsigned char h, unsigned char n, unsigned char s, unsigned u)
-{
- year = y;
- month = m;
- mday = d;
- hour = h;
- minute = n;
- second = s;
- usec = u;
-
if(usec>=1000000)
throw out_of_range("DateTime::DateTime usec");
if(second>=60)
string DateTime::format(const string &fmt) const
{
string result;
- for(string::const_iterator i=fmt.begin(); i!=fmt.end(); ++i)
+ for(auto i=fmt.begin(); i!=fmt.end(); ++i)
{
if(*i=='%')
{