Changeset 1785 for trunk/gsdl/lib
- Timestamp:
- 2000-12-12T13:55:22+13:00 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/lib/gsdltimes.cpp
r1779 r1785 117 117 } 118 118 119 // returns current date and time formatted like "Thu Dec 7 23:43:38 GMT 2000"119 // returns current date and time formatted like "Thu Dec 07 23:43:38 GMT 2000" 120 120 // if ltime is true return value will be expressed in local time, otherwise 121 // it'll be Coordinated Universal Time (UTC) 121 // it'll be Coordinated Universal Time (UTC) - no promises are made that the 122 // resulting string will be formatted exactly as expected, especially on windows 122 123 // returns "" if an error occurs 123 124 text_t get_date (bool ltime) { 124 125 125 char *timestr = new char[128];126 126 tm *tm_ptr = NULL; 127 127 time_t t = time(NULL); … … 129 129 else tm_ptr = gmtime (&t); 130 130 if (tm_ptr == NULL) return ""; 131 char *timestr = new char[128]; 132 text_t ret; 131 133 132 strftime (timestr, 128, "%a %b %e %T %Z %Y", tm_ptr); 133 text_t ret = timestr; 134 // we do this in such an ugly way because windows is kind of flakey when 135 // it comes to timezones 136 if (ltime) { 137 strftime (timestr, 128, "%a %b %d %H:%M:%S %z %Y", tm_ptr); 138 ret.setcstr (timestr); 139 } else { 140 strftime (timestr, 128, "%a %b %d %H:%M:%S", tm_ptr); 141 ret.setcstr (timestr); 142 ret += " GMT "; 143 strftime (timestr, 128, "%Y", tm_ptr); 144 ret += timestr; 145 } 146 134 147 delete timestr; 135 148 return ret;
Note:
See TracChangeset
for help on using the changeset viewer.