ffead.server.doc
Date.h
1 /*
2  Copyright 2009-2012, Sumeet Chhetri
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 /*
17  * Date.h
18  *
19  * Created on: Jun 4, 2010
20  * Author: sumeet
21  */
22 
23 #ifndef DATE_H_
24 #define DATE_H_
25 #include <time.h>
26 #include "string"
27 #include "vector"
28 #include "CastUtil.h"
29 #include "StringUtil.h"
30 
31 using namespace std;
32 
33 class Date {
34  string month;
35  string monthw;
36  string year;
37  string day;
38  int weekday;
39  string hh;
40  string mm;
41  string ss;
42  string dayw;
43  long long nanoseconds;
44  float timeZoneOffset;
45  string getMon(string);
46  string getMonFd(string);
47  long getDaysInt();
48  long getDays(long y,long m,long d);
49  long getHours(long y,long m,long d, long hh);
50  long getMinutes(long y,long m,long d, long hh, long mi);
51  unsigned long long getSeconds(long y,long m,long d, long hh, long mi, long ss);
52  Date getDateFromDays(long days);
53  void getDateFromHours(long hours);
54  void getDateFromMinutes(long long minutes);
55  void getDateFromSeconds(long long seconds);
56  void setMonthw(string monthw);
57  void setDayw(string dayw);
58  int getWeekDayVal(string dayName);
59  void setSs(int ss);
60  void setMm(int mm);
61  void setHh(int hh);
62  void setDay(int day);
63  void setYear(int year);
64  void setMonth(int month);
65 public:
66  Date();
67  Date(int yyyy,string mmm,int dd);
68  Date(int yyyy,int mm,int dd);
69  Date(int yy,string mmm,int dd,bool);
70  Date(int yy,int mm,int dd,bool);
71  void setTime(int hh,int mi,int ss);
72  virtual ~Date();
73  int getMonth();
74  string getMonthw() const;
75  int getYear() const;
76  int getDay() const;
77  int getHh() const;
78  int getMm() const;
79  int getSs() const;
80  long long getNanoSeconds() const;
81  string getDayw() const;
82  string toString();
83  string getDayStr() const;
84  string getMonthStr() const;
85  string getHhStr() const;
86  string getSsStr() const;
87  string getNsStr() const;
88  string getMmStr() const;
89  string getYearStr() const;
90  int getWeekDay() const;
91  Date addSeconds(long seconds);
92  Date addMinutes(long minutes);
93  Date addHours(long hours);
94  Date addDays(long days);
95  Date addMonths(long months);
96  Date addYears(long years);
97  static bool validateDate(int dd, int mm, int yyyy);
98  static string getDayName(int dd, int mm, int yyyy);
99  float getTimeZoneOffset();
100  void setTimeZoneOffset(float tzVal);
101  int test();
102 };
103 
104 #endif /* DATE_H_ */