pike.git
/
src
/
builtin.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/builtin.cmod:477:
struct tm *res = gmtime( &t ); if( !res ) RETURN 0; THIS->t = *res; THIS->modified = 1; RETURN 1; }
-
/*! Create a new @[TM] initialized from a unix time_t.
+
/*!
@decl void create(int t)
+
*!
Create a new @[TM] initialized from a unix time_t.
*! The timezone will always be UTC when using this function. */ PIKEFUN void create( int _t ) { f_TM_gmtime( 1 ); if( Pike_sp[-1].u.integer == 0 ) Pike_error("time out of range\n"); }
-
/*! Construct a new TM, all fields will be set to 0. */
+
/*!
@decl void create()
+
*!
Construct a new TM, all fields will be set to 0.
+
*/
PIKEFUN void create( ) { memset( &THIS->t, 0, sizeof( struct tm ) ); THIS->t.tm_isdst = -1; THIS->unix_time = 0; THIS->modified = 1; }
-
/*! Construct a new time using the given values.
+
/*!
@decl void create( int year, int(0..11) mon, int(1..31) mday, @
+
*! int(0..24) hour, int(0..59) min, int(0..59) sec, @
+
*! string|void timezone )
+
*!
Construct a new time using the given values.
*! Slightly faster than setting them individually. */ PIKEFUN void create( int year, int(0..11) mon, int(1..31) mday, int(0..24) hour, int(0..59) min, int(0..59) sec, string|void timezone ) { struct tm *t = &THIS->t; t->tm_isdst = -1;
-
t->tm_year = year;
+
t->tm_year = year
- 1900
;
t->tm_mon = mon; t->tm_mday = mday; t->tm_hour = hour; t->tm_min = min; t->tm_sec = sec;
-
+
if (THIS->set_zone) {
+
free_string(THIS->set_zone);
+
THIS->set_zone = NULL;
+
}
if( !timezone ) /* gmtime. */ t->tm_zone = "UTC"; else {
-
timezone
->refs++
;
+
add_ref(
timezone
)
;
THIS->set_zone = timezone; t->tm_zone = timezone->str; } THIS->unix_time = mktime_zone( t ); } INIT { THIS->set_zone = 0; THIS->modified = 0; }