mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / ndb / src / kernel / error / TimeModule.cpp
blob33acdbbf1cf63adfe761977aacc3c8e1e23703a4
1 /* Copyright (c) 2003-2007 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
18 #include <ndb_global.h>
19 #include "TimeModule.hpp"
21 static const char* cMonth[] = { "x", "January", "February", "March", "April", "May", "June",
22 "July", "August", "September", "October", "November", "December"};
24 static const char* cDay[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
25 "Saturday", "Sunday"};
27 static const char* cHour[] = { "00","01","02","03","04","05","06","07","08","09","10","11","12",
28 "13","14","15","16","17","18","19","20","21","22","23"};
30 static const char* cMinute[] = { "00","01","02","03","04","05","06","07","08","09","10","11","12",
31 "13","14","15","16","17","18","19","20","21","22","23","24","25",
32 "26","27","28","29","30","31","32","33","34","35","36","37","38",
33 "39","40","41","42","43","44","45","46","47","48","49","50","51",
34 "52","53","54","55","56","57","58","59"};
36 static const char* cSecond[] = { "00","01","02","03","04","05","06","07","08","09","10","11","12",
37 "13","14","15","16","17","18","19","20","21","22","23","24","25",
38 "26","27","28","29","30","31","32","33","34","35","36","37","38",
39 "39","40","41","42","43","44","45","46","47","48","49","50","51",
40 "52","53","54","55","56","57","58","59"};
43 TimeModule::TimeModule(){
46 TimeModule::~TimeModule(){
49 void
50 TimeModule::setTimeStamp()
52 struct tm* rightnow;
53 time_t now;
55 time(&now);
57 rightnow = localtime(&now);
59 iYear = rightnow->tm_year+1900; // localtime returns current year -1900
60 iMonth = rightnow->tm_mon+1; // and month 0-11
61 iMonthDay = rightnow->tm_mday;
62 iWeekDay = rightnow->tm_wday;
63 iHour = rightnow->tm_hour;
64 iMinute = rightnow->tm_min;
65 iSecond = rightnow->tm_sec;
68 int
69 TimeModule::getYear() const
71 return iYear;
74 int
75 TimeModule::getMonthNumber() const
77 return iMonth;
80 const char*
81 TimeModule::getMonthName() const {
82 return cMonth[iMonth];
85 int
86 TimeModule::getDayOfMonth() const {
87 return iMonthDay;
90 const char*
91 TimeModule::getDayName() const {
92 return cDay[iWeekDay];
95 const char*
96 TimeModule::getHour() const {
97 return cHour[iHour];
100 const char*
101 TimeModule::getMinute() const {
102 return cMinute[iMinute];
105 const char*
106 TimeModule::getSecond() const {
107 return cSecond[iSecond];