libtime++: Date and time calculation
now.cc
Go to the documentation of this file.
1 
36 #define TF_NOW_CC_VERSION \
37  "TF_NOW_CC V1.2"
38 
39 #include <libtime++.h>
40 #include <ctime>
41 
42 namespace libtime {
43 
45 {
46  std::time_t nowtime=std::time(NULL);
47  std::tm *nowtm=std::localtime(&nowtime);
48  int year=nowtm->tm_year+1900;
49  int month=nowtm->tm_mon+1;
50  int day=nowtm->tm_mday;
51  int hour=nowtm->tm_hour;
52  int minute=nowtm->tm_min;
53  int second=nowtm->tm_sec;
54  TAbsoluteTime thetime(year, month, day, hour, minute, second);
55  return(thetime);
56 } // now()
57 
59 {
60  std::time_t nowtime=std::time(NULL);
61  std::tm *nowtm=std::gmtime(&nowtime);
62  int year=nowtm->tm_year+1900;
63  int month=nowtm->tm_mon+1;
64  int day=nowtm->tm_mday;
65  int hour=nowtm->tm_hour;
66  int minute=nowtm->tm_min;
67  int second=nowtm->tm_sec;
68  TAbsoluteTime thetime(year, month, day, hour, minute, second);
69  return(thetime);
70 } // utc()
71 
72 } // namespace libtime
73 
74 /* ----- END OF now.cc ----- */
TAbsoluteTime utc()
return system time in UTC
Definition: now.cc:58
TAbsoluteTime now()
return system time
Definition: now.cc:44
class to contain absolute times
Definition: libtime++.h:149