Commit fafa2944 authored by Jan Becker's avatar Jan Becker
Browse files

[trunk] Add Time::LocalTimeZone() method

parent 19869c18
......@@ -754,6 +754,22 @@ Time Time::LocalTime() {
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
std::string Time::LocalTimeZone() {
time_t t;
struct tm *tm_;
char tz[40];
::time(&t);
tm_ = ::localtime(&t);
strftime(tz, sizeof(tz)-1, "%Z", tm_);
tz[sizeof(tz)-1] = '\0';
return tz;
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Time Time::GMT() {
Time t;
......@@ -1014,16 +1030,7 @@ bool Time::fromString(const char* str, const char* fmt) {
return false;
}
else {
time_t calendartime = timegm(&t);
if ( calendartime == -1 ) {
*this = (time_t)0;
return false;
}
*this = (time_t)0;
setUSecs(usec);
*this = calendartime;
*this = timegm(&t);
setUSecs(usec);
}
......
......@@ -184,6 +184,11 @@ class SC_SYSTEM_CORE_API Time : public TimeSpan {
//! Returns the current localtime
static Time LocalTime();
/**
* @return A string containing the local time zone name/abbreviation
*/
static std::string LocalTimeZone();
//! Returns the current gmtime
static Time GMT();
......@@ -195,10 +200,10 @@ class SC_SYSTEM_CORE_API Time : public TimeSpan {
static Time FromYearDay(int year, int year_day);
//! Saves the current localtime in the calling object
Time& localtime();
Time &localtime();
//! Saves the current gmtime in the calling object
Time& gmt();
Time &gmt();
//! Converts the time to localtime
Time toLocalTime() const;
......
......@@ -39,6 +39,7 @@ namespace Core {
API Changelog
******************************************************************************
"10.0.0" 0x0A0000
- Added Seiscomp::Core::Time::LocalTimeZone()
- Added Seiscomp::IO::GFArchive::getTravelTime(...)
- Added Seiscomp::Math::WindowFunc and several implementations
- Changed Seiscomp::Util::Bindings::getKeys to const
......@@ -48,6 +49,8 @@ namespace Core {
Seiscomp::Gui::Map::TileStore implementations
- Added Seiscomp::Gui::RecordView::coveredTimeRange()
- Added Seiscomp::Core::stringify(...)
- Added Seiscomp::Gui::timeToString()
- Added Seiscomp::Gui::timeToLabel(...)
"9.1.0" 0x090100
- Added Seiscomp::Client::Application::Stage enum PLUGINS
......
......@@ -627,6 +627,8 @@ class Time(TimeSpan):
def get2(self, yday=None): return _Core.Time_get2(self, yday)
__swig_getmethods__["LocalTime"] = lambda x: _Core.Time_LocalTime
if _newclass:LocalTime = staticmethod(_Core.Time_LocalTime)
__swig_getmethods__["LocalTimeZone"] = lambda x: _Core.Time_LocalTimeZone
if _newclass:LocalTimeZone = staticmethod(_Core.Time_LocalTimeZone)
__swig_getmethods__["GMT"] = lambda x: _Core.Time_GMT
if _newclass:GMT = staticmethod(_Core.Time_GMT)
__swig_getmethods__["FromYearDay"] = lambda x: _Core.Time_FromYearDay
......@@ -654,6 +656,10 @@ def Time_LocalTime():
return _Core.Time_LocalTime()
Time_LocalTime = _Core.Time_LocalTime
def Time_LocalTimeZone():
return _Core.Time_LocalTimeZone()
Time_LocalTimeZone = _Core.Time_LocalTimeZone
def Time_GMT():
return _Core.Time_GMT()
Time_GMT = _Core.Time_GMT
......
......@@ -12428,6 +12428,19 @@ fail:
}
 
 
SWIGINTERN PyObject *_wrap_Time_LocalTimeZone(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
std::string result;
if (!PyArg_ParseTuple(args,(char *)":Time_LocalTimeZone")) SWIG_fail;
result = Seiscomp::Core::Time::LocalTimeZone();
resultobj = SWIG_From_std_string(static_cast< std::string >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_Time_GMT(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
Seiscomp::Core::Time result;
......@@ -35785,6 +35798,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"Time_get", _wrap_Time_get, METH_VARARGS, NULL},
{ (char *)"Time_get2", _wrap_Time_get2, METH_VARARGS, NULL},
{ (char *)"Time_LocalTime", _wrap_Time_LocalTime, METH_VARARGS, NULL},
{ (char *)"Time_LocalTimeZone", _wrap_Time_LocalTimeZone, METH_VARARGS, NULL},
{ (char *)"Time_GMT", _wrap_Time_GMT, METH_VARARGS, NULL},
{ (char *)"Time_FromYearDay", _wrap_Time_FromYearDay, METH_VARARGS, NULL},
{ (char *)"Time_localtime", _wrap_Time_localtime, METH_VARARGS, NULL},
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment