RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
00001 /* time_arithmetic.h -*- C++ -*- 00002 Jeremy Barnes, 4 April 2012 00003 Copyright (c) 2012 Datacratic. All rights reserved. 00004 00005 Arithmetic functions for time. 00006 */ 00007 00008 #ifndef __logger__periodic_utils_h__ 00009 #define __logger__periodic_utils_h__ 00010 00011 #include "date.h" 00012 00013 namespace Datacratic { 00014 00015 enum TimeGranularity { 00016 MILLISECONDS, 00017 SECONDS, 00018 MINUTES, 00019 HOURS, 00020 DAYS, 00021 WEEKS, 00022 MONTHS, 00023 YEARS 00024 }; 00025 00027 std::pair<Date, double> 00028 findPeriod(Date now, TimeGranularity granularity, int interval); 00029 00030 std::pair<Date, double> 00031 findPeriod(Date now, const std::string & granularityName); 00032 00091 std::string filenameFor(const Date & date, 00092 const std::string & pattern); 00093 00094 std::pair<TimeGranularity, int> 00095 parsePeriod(const std::string & pattern); 00096 00097 } // namespace Datacratic 00098 00099 #endif /* __logger__periodic_utils_h__ */ 00100