void BuiltIns::_f_utc_difference(Context* context) { /* arguments: utc_difference returnvalue: <T_INTEGER> description: Returns the difference of local time and UTC time (timezone and DST-adjusted) in seconds. (UTC + difference = localtime) notes: May be negative. */ pushInteger(TZoffset.total_seconds()); }
/*! \fn CPlayloop::sleep(int duration) */ int CPlayloop::sleep(time_duration duration) { int retval = 0; if( !duration.is_negative() ) { struct timespec ts_to_sleep, ts_remaining; ts_to_sleep.tv_sec = duration.total_seconds(); ts_to_sleep.tv_nsec = duration.fractional_seconds(); //boost::date_time::time_resolutions if (time_duration::resolution() == boost::date_time::micro) { ts_to_sleep.tv_nsec *= 1000; } int retval = nanosleep( &ts_to_sleep, &ts_remaining); if(retval != 0) cerr << "nanosleep returned early due to a signal!" << endl; } return retval; }
inline int total_seconds(time_duration td) { return td.total_seconds(); }
int User::to_minutes(time_duration duration) { return duration.total_seconds() / 60; }
int64_t localTime() { static const ptime epoch(date(1970, 1, 1)); const time_duration diff = second_clock::local_time() - epoch; return diff.total_seconds(); }
int64_t str2time(const string& str) { static const ptime epoch(date(1970, 1, 1)); const ptime string_time = from_iso_string(str); const time_duration diff = string_time - epoch; return diff.total_seconds(); }