summaryrefslogtreecommitdiffstats
path: root/time/akg_localtime.cc
diff options
context:
space:
mode:
Diffstat (limited to 'time/akg_localtime.cc')
-rw-r--r--time/akg_localtime.cc60
1 files changed, 60 insertions, 0 deletions
diff --git a/time/akg_localtime.cc b/time/akg_localtime.cc
new file mode 100644
index 0000000..0831cbc
--- /dev/null
+++ b/time/akg_localtime.cc
@@ -0,0 +1,60 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+
+/*
+ * 2007-feb-07 PB #include <akgtime.hh> -> "akgtime.hh"
+ */
+
+#include "akgtime.hh"
+#include <iomanip>
+
+using namespace akg;
+
+
+LocalTime::LocalTime() throw()
+ {
+ now();
+ }
+
+void LocalTime::now() throw()
+ {
+ //gettimeofday(&value,NULL);
+ value = time(NULL);
+ }
+
+std::ostream& akg::operator<<(std::ostream &os, const LocalTime &lt)
+ {
+ struct tm broken;
+
+ localtime_r(&lt.value, &broken);
+
+ os<<std::setw(2)<<broken.tm_mday<<'.';
+ os<<std::setw(2)<<std::setfill('0')<<broken.tm_mon+1;
+ os<<'.'<<broken.tm_year+1900<<' ';
+ os<<std::setw(2)<<std::setfill('0')<<broken.tm_hour<<':';
+ os<<std::setw(2)<<std::setfill('0')<<broken.tm_min<<':';
+ os<<std::setw(2)<<std::setfill('0')<<broken.tm_sec;
+
+ return os;
+ }
+