Changeset 1778 for trunk/gsdl/lib
- Timestamp:
- 2000-12-08T17:00:35+13:00 (23 years ago)
- Location:
- trunk/gsdl/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/lib/gsdltimes.cpp
r1310 r1778 26 26 #include "gsdltimes.h" 27 27 28 28 // returns a string of the form "YYYY/MM/DD hh:mm:ss" (expressed in 29 // Coordinated Universal Time (UTC)) 29 30 // returns "" if an error occurs 30 31 text_t time2text (time_t time) { … … 63 64 } 64 65 66 // takes a string like that returned by time2text and returns corresponding time_t 65 67 // returns -1 if an error occurs 66 68 time_t text2time (const text_t ×tr) { … … 114 116 return mktime (&timetm); 115 117 } 118 119 // returns current date and time formatted like "Thu Dec 7 23:43:38 2000" 120 // if ltime is true return value will be expressed in local time, otherwise 121 // it'll be Coordinated Universal Time (UTC) 122 // returns "" if an error occurs 123 text_t get_date (bool ltime) { 124 125 char *timestr; 126 tm *tm_ptr = NULL; 127 time_t t = time(NULL); 128 if (ltime) tm_ptr = localtime (&t); 129 else tm_ptr = gmtime (&t); 130 if (tm_ptr == NULL) return ""; 131 132 strftime (timestr, 128, "%a %b %e %T %Y", tm_ptr); 133 text_t ret = timestr; 134 return ret; 135 } -
trunk/gsdl/lib/gsdltimes.h
r1310 r1778 39 39 time_t text2time (const text_t ×tr); 40 40 41 42 // returns formatted date in local or UTC time 43 // returns "" if an error occurs 44 text_t get_date (bool ltime); 45 41 46 #endif
Note:
See TracChangeset
for help on using the changeset viewer.