Added parameter used to build UTC time instead of local one when formatting date/time.

git-svn-id: http://voip.null.ro/svn/yate@2198 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
marian 2008-09-15 14:05:15 +00:00
parent d985d9e34b
commit 26642b15ee
3 changed files with 26 additions and 11 deletions

View File

@ -1835,14 +1835,26 @@ bool QtClient::createSound(const char* name, const char* file, const char* devic
return true;
}
bool QtClient::formatDateTime(String& dest, unsigned int secs, const char* format)
// Build a date/time string from UTC time
bool QtClient::formatDateTime(String& dest, unsigned int secs,
const char* format, bool utc)
{
if (!(format && *format))
return false;
dest = qtGetUtf8(formatDateTime(secs,format));
dest = qtGetUtf8(formatDateTime(secs,format,utc));
return true;
}
// Build a date/time QT string from UTC time
QString QtClient::formatDateTime(unsigned int secs, const char* format, bool utc)
{
QDateTime time;
if (utc)
time.setTimeSpec(Qt::UTC);
time.setTime_t(secs);
return time.toString(format);
}
// Set/get an object's property
bool QtClient::property(bool set, QObject* obj, const char* name, String& value)
{

View File

@ -149,24 +149,25 @@ public:
virtual bool createSound(const char* name, const char* file, const char* device = 0);
/**
* Build a date/time string
* Build a date/time string from UTC time
* @param dest Destination string
* @param secs Seconds since EPOCH
* @param format Format string used to build the destination
* @param utc True to build UTC time instead of local time
* @return True on success
*/
virtual bool formatDateTime(String& dest, unsigned int secs, const char* format);
virtual bool formatDateTime(String& dest, unsigned int secs, const char* format,
bool utc = false);
/**
* Build a date/time QT string
* Build a date/time QT string from UTC time
* @param secs Seconds since EPOCH
* @param format Format string
* @param utc True to build UTC time instead of local time
* @return The formated string
*/
static QString formatDateTime(unsigned int secs, const char* format) {
QDateTime time = QDateTime::fromTime_t(secs);
return time.toString(format);
}
static QString formatDateTime(unsigned int secs, const char* format,
bool utc = false);
/**
* Set or get an object's property

View File

@ -1111,13 +1111,15 @@ public:
bool setBoolOpt(ClientToggle toggle, bool value, bool updateUi = false);
/**
* Build a date/time string
* Build a date/time string from UTC time
* @param dest Destination string
* @param secs Seconds since EPOCH
* @param format Format string used to build the destination
* @param utc True to build UTC time instead of local time
* @return True on success
*/
virtual bool formatDateTime(String& dest, unsigned int secs, const char* format)
virtual bool formatDateTime(String& dest, unsigned int secs, const char* format,
bool utc = false)
{ return false; }
/**