71   Set(year, month, day, hour, min, sec);
 
   88   static TString weekDays[7] = { 
"Mon", 
"Tue", 
"Wed", 
"Thu", 
"Fri", 
"Sat", 
"Sun" };
 
   91   for (day = 0; day < 7; day++) {
 
   92      if (wd(0, 3) == weekDays[day])
 
   95   return (day < 7) ? day+1: -1;
 
  105   char *retStr = ctime(&t);
 
  110      static const char *defaulttime = 
"15/06/96";
 
  111      Error(
"TDatime::AsString", 
"could not get time string");
 
  125#if defined(R__SOLARIS) && (_POSIX_C_SOURCE - 0 < 199506L) 
  126   char *retStr = ctime_r(&t, out, 26);
 
  128   char *retStr = ctime_r(&t, out);
 
  131   char *retStr = ctime(&t);
 
  140      static const char *defaulttime = 
"15/06/96";
 
  141      strcpy(out, defaulttime);
 
  142      Error(
"TDatime::AsString", 
"could not get time string");
 
  154   static char sqldate[20];
 
  157   UInt_t month = (fDatime<<6)>>28;
 
  158   UInt_t day   = (fDatime<<10)>>27;
 
  159   UInt_t hour  = (fDatime<<15)>>27;
 
  160   UInt_t min   = (fDatime<<20)>>26;
 
  161   UInt_t sec   = (fDatime<<26)>>26;
 
  163   snprintf(sqldate,20, 
"%04d-%02d-%02d %02d:%02d:%02d", (year+1995), month, day,
 
  185   UInt_t month = (fDatime<<6)>>28;
 
  186   UInt_t day   = (fDatime<<10)>>27;
 
  187   UInt_t hour  = (fDatime<<15)>>27;
 
  188   UInt_t min   = (fDatime<<20)>>26;
 
  189   UInt_t sec   = (fDatime<<26)>>26;
 
  192   tp.tm_year  = year+95;
 
  200   time_t t = mktime(&tp);
 
  202      Error(
"TDatime::Convert", 
"error converting fDatime to time_t");
 
  208      struct tm *tgp = gmtime_r(&t, &tg);
 
  210      struct tm *tgp = gmtime(&t);
 
  251   UInt_t month = (fDatime<<6)>>28;
 
  252   UInt_t day   = (fDatime<<10)>>27;
 
  253   return 10000*(year+1995) + 100*month + day;
 
  261   UInt_t hour  = (fDatime<<15)>>27;
 
  262   UInt_t min   = (fDatime<<20)>>26;
 
  263   UInt_t sec   = (fDatime<<26)>>26;
 
  264   return 10000*hour + 100*min + sec;
 
  272   printf(
"Date/Time = %s\n", 
AsString());
 
  292   time_t tloc   = time(
nullptr);
 
  294   struct tm *tp = localtime_r(&tloc, &tpa);
 
  295   UInt_t year   = tp->tm_year;
 
  296   UInt_t month  = tp->tm_mon + 1;
 
  298   UInt_t hour   = tp->tm_hour;
 
  304   UInt_t year   = tp.wYear-1900;
 
  312   fDatime = (year-95)<<26 | month<<22 | day<<17 | hour<<12 | min<<6 | sec;
 
  323   UInt_t year, month, day, hour, min, sec;
 
  326      year  = ((tloc >> 25) & 0x7f) + 80;
 
  327      month = ((tloc >> 21) & 0xf);
 
  328      day   = (tloc >> 16) & 0x1f;
 
  329      hour  = (tloc >> 11) & 0x1f;
 
  330      min   = (tloc >> 5) & 0x3f;
 
  331      sec   = (tloc & 0x1f) * 2;
 
  333      time_t t = (time_t) tloc;
 
  336      struct tm *tp = localtime_r(&t, &tpa);
 
  338      struct tm *tp = localtime(&t);
 
  341      month  = tp->tm_mon + 1;
 
  348   fDatime = (year-95)<<26 | month<<22 | day<<17 | hour<<12 | min<<6 | sec;
 
  361   if (date > 19000000) date -= 19000000;
 
  363      Error(
"TDatime::Set", 
"year smaller than 1995");
 
  367   Int_t year  = date/10000;
 
  368   Int_t month = (date-year*10000)/100;
 
  369   Int_t day   = date%100;
 
  371   Int_t hour, min, sec;
 
  374   min  = (time-hour*10000)/100;
 
  377   fDatime = (year-95)<<26 | month<<22 | day<<17 | hour<<12 | min<<6 | sec;
 
  387   if (year < 159) year += 1900;
 
  389      Error(
"TDatime::Set", 
"year must be >= 1995");
 
  393   fDatime = (year-1995)<<26 | month<<22 | day<<17 | hour<<12 | min<<6 | sec;
 
  402   Int_t yy, mm, dd, hh, mi, ss;
 
  404   if (sscanf(sqlDateTime, 
"%d-%d-%d %d:%d:%d", &yy, &mm, &dd, &hh, &mi, &ss) == 6)
 
  405      Set(yy, mm, dd, hh, mi, ss);
 
  407      Error(
"TDatime(sqlDatTime)", 
"input string not in right format, set" 
  408            " to current date/time");
 
  433   UInt_t year  = datetime>>26;
 
  434   UInt_t month = (datetime<<6)>>28;
 
  435   UInt_t day   = (datetime<<10)>>27;
 
  436   UInt_t hour  = (datetime<<15)>>27;
 
  437   UInt_t min   = (datetime<<20)>>26;
 
  438   UInt_t sec   = (datetime<<26)>>26;
 
  439   date         =  10000*(year+1995) + 100*month + day;
 
  440   time         =  10000*hour + 100*min + sec;
 
  452   Int_t dy = date / 10000;
 
  453   Int_t dm = (date - dy*10000)/100;
 
  454   Int_t dd = (date - dy*10000 - dm*100);
 
  458   return y*365 + 
y/4 - 
y/100 + 
y/400 + (
m*306 + 5)/10 + (dd - 1);
 
  469   Int_t y = 
int((10000*ld + 14780)/3652425);
 
  470   Int_t ddd = day - (
y*365 + 
y/4 - 
y/100 + 
y/400);
 
  473      ddd = day - (
y*365 + 
y/4 - 
y/100 + 
y/400);
 
  475   Int_t mi = (52 + 100*ddd)/3060;
 
  476   Int_t dy = 
y + (mi + 2)/12;
 
  477   Int_t dm = (mi + 2)%12 + 1;
 
  478   Int_t dd = ddd - (mi*306 + 5)/10 + 1;
 
  480   return dy*10000 + dm*100 + dd;
 
  494   static Int_t calstart = 0;
 
  499      ::Warning(
"TDatime::GetLegalGlobalDayFromDate", 
"dates before Oct. 1582 are inaccurate.");
 
  502      ::Error(
"TDatime::GetLegalGlobalDayFromDate", 
"illegal date %d", dte);
 
  511std::string cling::printValue(
const TDatime* val) {
 
  513   return std::string(val->
AsString(buf));
 
void frombuf(char *&buf, Bool_t *x)
void tobuf(char *&buf, Bool_t x)
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Buffer base class used for serializing objects.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
static Int_t GetGlobalDayFromDate(Int_t date)
Static function that returns the global day number from date.
static Int_t GetDateFromGlobalDay(Int_t day)
Static function that returns the date from the global day number.
void Copy(TDatime &datime) const
Copy this to datime.
static Int_t GetLegalGlobalDayFromDate(Int_t date)
Static function that returns the global day number from date.
Int_t GetDate() const
Return date in form of 19971224 (i.e. 24/12/1997)
UInt_t Get() const
Return raw date/time as encoded by TDatime.
void FillBuffer(char *&buffer)
Encode Date/Time into buffer, used by I/O system.
Int_t GetDayOfWeek() const
Returns day of week, with Monday being day 1 and Sunday day 7.
void Print(Option_t *option="") const
Print date and time.
const char * AsSQLString() const
Return the date & time in SQL compatible string format, like: 1997-01-15 20:16:28.
virtual void Streamer(TBuffer &)
Stream a object of type TDatime.
TDatime()
Create a TDatime and set it to the current time.
void Set()
Set Date/Time to current time as reported by the system.
UInt_t Convert(Bool_t toGMT=kFALSE) const
Convert fDatime from TDatime format to the standard time_t format.
Int_t GetTime() const
Return time in form of 123623 (i.e. 12:36:23)
static void GetDateTime(UInt_t datetime, Int_t &date, Int_t &time)
Static function that returns the date and time.
const char * AsString() const
Return the date & time as a string (ctime() format).
void ReadBuffer(char *&buffer)
Decode Date/Time from output buffer, used by I/O system.