00001 /* 00002 Copyright (C) 2007 Butterfat, LLC (http://butterfat.net) 00003 00004 Permission is hereby granted, free of charge, to any person 00005 obtaining a copy of this software and associated documentation 00006 files (the "Software"), to deal in the Software without 00007 restriction, including without limitation the rights to use, 00008 copy, modify, merge, publish, distribute, sublicense, and/or sell 00009 copies of the Software, and to permit persons to whom the 00010 Software is furnished to do so, subject to the following 00011 conditions: 00012 00013 The above copyright notice and this permission notice shall be 00014 included in all copies or substantial portions of the Software. 00015 00016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00017 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 00018 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00019 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 00020 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 00021 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00022 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00023 OTHER DEALINGS IN THE SOFTWARE. 00024 00025 Created by bmuller <bmuller@butterfat.net> 00026 */ 00027 00028 namespace stactiverecord { 00029 00030 class DateTime { 00031 public: 00032 struct tm t; 00033 DateTime(tm * _t) { from_tm(_t); }; 00034 DateTime(int month=0, int day=1, int year=0, int hour=0, int minute=0, int second=0); 00035 void set(int month=0, int day=1, int year=0, int hour=0, int minute=0, int second=0); 00036 void to_string(std::string& s); 00037 int to_int(); 00038 void from_int(int i); 00039 void from_tm(tm * tm); 00040 bool operator==(DateTime& other); 00041 bool operator!=(DateTime& other); 00042 void dump() { std::string s; to_string(s); std::cout << s << "\n"; }; 00043 static int now() { time_t rawtime; time(&rawtime); return (int) rawtime; }; 00044 }; 00045 };