Revision: 57176
http://sourceforge.net/p/brlcad/code/57176
Author: tbrowder2
Date: 2013-08-27 15:05:15 +0000 (Tue, 27 Aug 2013)
Log Message:
-----------
add function to provide an ISO time (planned to be used for attribute mod and
creation times); will provide a regression test later
Modified Paths:
--------------
brlcad/trunk/include/bu.h
brlcad/trunk/src/libbu/CMakeLists.txt
Added Paths:
-----------
brlcad/trunk/src/libbu/date-time.c
Modified: brlcad/trunk/include/bu.h
===================================================================
--- brlcad/trunk/include/bu.h 2013-08-27 14:53:34 UTC (rev 57175)
+++ brlcad/trunk/include/bu.h 2013-08-27 15:05:15 UTC (rev 57176)
@@ -6190,6 +6190,17 @@
/** @addtogroup file */
/** @ingroup io */
/** @{ */
+/** @file libbu/date-time.c
+ * Put the current UTC time in ISO format into the user-provided
+ * bu_vls struct.
+ */
+BU_EXPORT void bu_gmtime(struct bu_vls *vls_gmtime);
+
+/** @} */
+
+/** @addtogroup file */
+/** @ingroup io */
+/** @{ */
/** @file libbu/dlfcn.c
* Dynamic Library functionality
*/
Modified: brlcad/trunk/src/libbu/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/libbu/CMakeLists.txt 2013-08-27 14:53:34 UTC (rev
57175)
+++ brlcad/trunk/src/libbu/CMakeLists.txt 2013-08-27 15:05:15 UTC (rev
57176)
@@ -29,6 +29,7 @@
ctype.c
dirent.c
dirname.c
+ date-time.c
dlfcn.c
endian.c
escape.c
Added: brlcad/trunk/src/libbu/date-time.c
===================================================================
--- brlcad/trunk/src/libbu/date-time.c (rev 0)
+++ brlcad/trunk/src/libbu/date-time.c 2013-08-27 15:05:15 UTC (rev 57176)
@@ -0,0 +1,72 @@
+/* D A T E - T I M E . C
+ * BRL-CAD
+ *
+ * Copyright (c) 2013-2013 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+
+#include "common.h"
+
+/*
+#include <stdio.h>
+#include <string.h>
+*/
+
+#include <time.h>
+
+#include "bu.h"
+
+void
+bu_gmtime(struct bu_vls *vls_gmtime)
+{
+ struct tm loctime;
+ struct tm* retval;
+ time_t curr_time = time(0);
+ BU_CK_VLS(vls_gmtime);
+
+ if (curr_time == (time_t)(-1)) {
+ /* time error: but set something */
+ bu_vls_sprintf(vls_gmtime, "TIME_ERROR");
+ return;
+ }
+
+ retval = gmtime_r(&curr_time, &loctime);
+ if (retval != &loctime) {
+ /* time error: but set something */
+ bu_vls_sprintf(vls_gmtime, "TIME_ERROR");
+ return;
+ }
+
+ /* put the UTC time in the desired ISO format: "yyyy-mm-ddThh:mm:ssZ" */
+ bu_vls_sprintf(vls_gmtime, "%04d-%02d-%02dT%02d:%02d:%02dZ",
+ loctime.tm_year + 1900,
+ loctime.tm_mon + 1,
+ loctime.tm_mday,
+ loctime.tm_hour,
+ loctime.tm_min,
+ loctime.tm_sec);
+}
+
+
+/*
+ * Local Variables:
+ * mode: C
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
Property changes on: brlcad/trunk/src/libbu/date-time.c
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits