int utc_time_since_2018() { static time_t utc_time_2018; if (!utc_time_2018) { struct tm tm; memset(&tm, 0, sizeof (tm)); tm.tm_isdst = 0; tm.tm_yday = 0; // Jan 1 tm.tm_wday = 1; // Monday tm.tm_year = 118; // 2018 tm.tm_mon = 0; // Jan tm.tm_mday = 1; // Jan 1 tm.tm_hour = 0; // midnight tm.tm_min = 0; tm.tm_sec = 0; utc_time_2018 = timegm(&tm); } return (utc_time() - utc_time_2018); }
/* Inside-the-game time should be read from flags.turntime, almost always. However, something has to look at the clock to set flags.turntime, so here we are. This should only be called from log_time_line, or functions that are similarly aware of save file discipline; otherwise this will cause save desyncs. */ microseconds time_for_time_line(void) { return utc_time() + ((microseconds)flags.timezone * 1000000LL); }
const char * begin_dump(int how) { const char *timestamp, *dumpname, *status, *rolename; time_t t; struct tm *tmp; /* back up the window procs */ winprocs_original = windowprocs; /* Make a timestamp like "2011-11-30 18:45:00". This now uses UTC time, in accordance with the timebase rules (in particular, we never look at the system timezone). This also avoids clashes when there are two games an hour apart and DST changed in between. (It doesn't help when there are two games in the same second, but that only happens as a result of extreme startscumming.) */ t = (time_t)(utc_time() / 1000000LL); tmp = gmtime(&t); if (tmp) timestamp = msgstrftime(TIMESTAMP_FORMAT, tmp); else timestamp = "unknown time"; /* previously "???" but that's illegal on many filesystems */ switch (how) { case ASCENDED: status = "ascended"; break; case QUIT: status = "quit"; break; case ESCAPED: status = "escaped"; break; default: status = "died"; break; } dumpname = msgprintf("%s, %s-%s-%s-%s-%s, %s.txt", timestamp, u.uplname, urole.filecode, urace.filecode, genders[u.ufemale].filecode, aligns[1 - u.ualign.type].filecode, status); dumpfp = fopen_datafile(dumpname, "w+", DUMPPREFIX); if (!dumpfp) return NULL; #ifdef UNIX fchmod(fileno(dumpfp), 0644); #endif rolename = (u.ufemale && urole.name.f) ? urole.name.f : urole.name.m; fprintf(dumpfp, "%s, %s %s %s %s\n", u.uplname, aligns[1 - u.ualign.type].adj, genders[u.ufemale].adj, urace.adj, rolename); dump_screen(dumpfp); dump_status(); return dumpname; }
boost::posix_time::ptime system_time() { // L'ora di sistema è espressa in utc return utc_time(); }