RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
00001 /* date.h -*- C++ -*- 00002 Wolfgang Sourdeau, 10 December 2012 00003 Copyright (c) 2012 Datacratic. All rights reserved. 00004 00005 Timezone-aware implementation of the Date class. 00006 */ 00007 00008 #pragma once 00009 00010 #include <string> 00011 #include <boost/date_time/posix_time/ptime.hpp> 00012 00013 namespace Datacratic { 00014 00015 /*****************************************************************************/ 00016 /* LOCALDATE */ 00017 /*****************************************************************************/ 00018 00019 struct LocalDate { 00020 LocalDate(double secondsSinceEpoch = 0, const std::string & tzName = "UTC"); 00021 00022 double secondsSinceEpoch() const; 00023 const std::string timezone() const; 00024 int tzOffset() const; 00025 00026 int hour() const; 00027 int dayOfMonth() const; 00028 int dayOfWeek() const; 00029 int year() const; 00030 00031 private: 00032 double secondsSinceEpoch_; 00033 std::string tzName_; 00034 int tzOffset_; /* updated when either secondsSinceEpoch_ or tzName_ 00035 * changes */ 00036 00037 void fillTM(struct tm & time) const; 00038 00039 void recomputeTZOffset(); 00040 }; 00041 00042 } // namespace Datacratic