4 #include <boost/date_time/local_time/local_time.hpp> 27 std::string
str()
const {
return ptr; }
30 class Time :
public boost::posix_time::ptime
63 Time(
const boost::date_time::special_values &val);
64 Time(
const time_t &tm,
const suseconds_t &us);
65 Time(
const timeval &tm);
66 Time(
const ptime &pt) :
boost::posix_time::ptime(pt) { }
67 Time(
short year,
unsigned char month,
unsigned char day,
68 unsigned char h=0,
unsigned char m=0,
unsigned char s=0,
70 Time(
double mjd) { Mjd(mjd); }
73 std::stringstream stream;
79 std::string GetAsStr(
const char *fmt=
"%Y-%m-%d %H:%M:%S")
const;
80 void SetFromStr(
const std::string &
str,
const char *fmt=
"%Y-%m-%d %H:%M:%S");
82 std::string Iso()
const;
87 double JD()
const {
return Mjd()+2400000.5; }
90 bool IsValid()
const {
return *
this != boost::date_time::not_special; }
91 bool operator!()
const {
return *
this == boost::date_time::not_special; }
94 unsigned short Y()
const {
return date().year(); }
95 unsigned short M()
const {
return date().month(); }
96 unsigned short D()
const {
return date().day(); }
98 unsigned short h()
const {
return time_of_day().hours(); }
99 unsigned short m()
const {
return time_of_day().minutes(); }
100 unsigned short s()
const {
return time_of_day().seconds(); }
102 unsigned int ms()
const {
return time_of_day().total_milliseconds()%1000; }
103 unsigned int us()
const {
return time_of_day().total_microseconds()%1000000; }
105 double SecondsOfDay()
const;
107 time_t Time_t()
const;
108 double UnixTime()
const;
109 double UnixDate()
const;
110 double RootTime()
const;
111 uint64_t
JavaDate()
const {
return IsValid() ? uint64_t(UnixTime()*1000) : 0; }
113 std::string MinutesTo(
const Time & =
Time())
const;
114 std::string SecondsTo(
const Time & =
Time())
const;
116 Time GetPrevSunRise(
double horizon)
const;
117 Time GetNextSunRise(
double horizon)
const;
119 Time GetPrevSunRise()
const;
120 Time GetNextSunRise()
const;
122 uint32_t NightAsInt()
const;
static const _time_format sql
set to format to the iso standard
uint64_t JavaDate() const
Adds some functionality to boost::posix_time::ptime for our needs.
static const _time_format iso
set to format to the sql format (without the fraction of seconds)
Time(const std::string &str)
static const _time_format reset
static const _time_format ssql
set to format to the sql format
static const _time_format magic
set to format to the extended iso standard
static const boost::gregorian::date fUnixOffset
Points to the famous 1/1/1970, the standard offset for unix times.
static const _time_format def
Remove the format description from the stream.
static const Time None
A none-time, this can be used as a simple representation of an invalid time.
static const _time_format std
set to format to the locale default
static const _time_format smagic
set to format to the MAGIC report format
Do not initialize the time.
init_t
set to format to the MAGIC report format (without the fraction of seconds)