Commit d5852ddc authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

New functions: [gm]time_to_isoDateTimeStr()

Not as flexible with regards to formatting as xpDateTime_to_isoDateTimeStr()
but simpler to use (with a time_t source).
parent c0e857c9
Pipeline #3665 passed with stage
in 6 minutes and 5 seconds
......@@ -572,8 +572,7 @@ static char* format_datetime(time_t t, char* str, size_t size)
if(t == 0)
*str = '\0';
else
safe_snprintf(str, size, "%" PRIu32 "T%06" PRIu32 "Z"
,gmtime_to_isoDate(t), gmtime_to_isoTime(t));
gmtime_to_isoDateTimeStr(t, str, size);
return str;
}
......
/* xpdatetime.c */
/* Cross-platform (and eXtra Precision) date/time functions */
/* $Id: xpdatetime.c,v 1.13 2015/11/25 07:27:07 sbbs Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
......@@ -17,21 +13,9 @@
* See the GNU Lesser General Public License for more details: lgpl.txt or *
* http://www.fsf.org/copyleft/lesser.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
......@@ -389,6 +373,20 @@ char* xpDateTime_to_isoDateTimeStr(xpDateTime_t dt
return str;
}
char* time_to_isoDateTimeStr(time_t t, xpTimeZone_t zone, char* str, size_t maxlen)
{
snprintf(str, maxlen, "%" PRIu32 "T%06" PRIu32 "%d"
,time_to_isoDate(t), time_to_isoTime(t), zone);
return str;
}
char* gmtime_to_isoDateTimeStr(time_t t, char* str, size_t maxlen)
{
snprintf(str, maxlen, "%" PRIu32 "T%06" PRIu32 "Z"
,gmtime_to_isoDate(t), gmtime_to_isoTime(t));
return str;
}
/****************************************************************************/
/* isoDate/Time/Zone String parsing functions */
/****************************************************************************/
......
......@@ -138,6 +138,10 @@ DLLEXPORT char* xpDateTime_to_isoDateTimeStr(xpDateTime_t
,const char* date_sep, const char* datetime_sep, const char* time_sep
,int precision
,char* str, size_t maxlen);
DLLEXPORT char* time_to_isoDateTimeStr(time_t, xpTimeZone_t
,char* str, size_t maxlen);
DLLEXPORT char* gmtime_to_isoDateTimeStr(time_t
,char* str, size_t maxlen);
#if defined(__cplusplus)
}
......
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