/* settimestamp(seconds1970) sets the date and time from a single parameter: the * number of seconds since 1 January 1970. */ static cell AMX_NATIVE_CALL n_settimestamp(AMX *amx, const cell *params) { #if defined __WIN32__ || defined _WIN32 || defined WIN32 int year, month, day, hour, minute, second; stamp2datetime(params[1], &year, &month, &day, &hour, &minute, &second); setdate(year, month, day); settime(hour, minute, second); #else /* Linux/Unix (and some DOS compilers) have stime(); on Linux/Unix, you * must have "root" permission to call stime(); many POSIX systems will * have settimeofday() instead */ #if defined __APPLE__ /* also valid for other POSIX systems */ struct timeval tv; tv.tv_sec = params[1]; tv.tv_usec = 0; settimeofday(&tv, 0); #else time_t sec1970=(time_t)params[1]; stime(&sec1970); #endif #endif (void)amx; return 0; }
/* cvttimestamp(seconds1970, &year, &month, &day, &hour, &minute, &second) */ static cell AMX_NATIVE_CALL n_cvttimestamp(AMX *amx, const cell *params) { int year, month, day, hour, minute, second; (void)amx; stamp2datetime(params[1], &year, &month, &day, &hour, &minute, &second); return 0; }
/* settimestamp(seconds1970) sets the date and time from a single parameter: the * number of seconds since 1 January 1970. */ static cell AMX_NATIVE_CALL n_settimestamp(AMX *amx, const cell *params) { #if defined __WIN32__ || defined _WIN32 || defined WIN32 int year, month, day, hour, minute, second; stamp2datetime(params[1], &year, &month, &day, &hour, &minute, &second); setdate(year, month, day); settime(hour, minute, second); #else /* Linux/Unix (and some DOS compilers) have stime(); on Linux/Unix, you * must have "root" permission to call stime() */ time_t sec1970=(time_t)params[1]; stime(&sec1970); #endif (void)amx; return 0; }