pike.git
/
src
/
builtin.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/builtin.cmod:50:
*/ { CVAR struct tm t; CVAR time_t unix_time; CVAR int modified; CVAR struct pike_string *set_zone; #ifdef STRUCT_TM_HAS___TM_GMTOFF #define tm_zone __tm_zone #define tm_gmtoff __tm_gmtoff
+
#define GET_GMTOFF(TM) ((TM)->tm_gmtoff)
+
#define GET_ZONE(TM) ((TM)->tm_zone)
+
#define SET_GMTOFF(TM, VAL) (((TM)->tm_gmtoff) = (VAL))
+
#define SET_ZONE(TM, VAL) (((TM)->tm_zone) = (VAL))
+
#elif defined(STRUCT_TM_HAS_GMTOFF)
+
#define GET_GMTOFF(TM) ((TM)->tm_gmtoff)
+
#define GET_ZONE(TM) ((TM)->tm_zone)
+
#define SET_GMTOFF(TM, VAL) (((TM)->tm_gmtoff) = (VAL))
+
#define SET_ZONE(TM, VAL) (((TM)->tm_zone) = (VAL))
+
#else
+
#define GET_GMTOFF(TM) 0
+
#define GET_ZONE(TM) ((char*)NULL)
+
#define SET_GMTOFF(TM, VAL) (VAL)
+
#define SET_ZONE(TM, VAL) (VAL)
#endif #if 0 /* This is supposed to make any timezone work. * However: It does not really work. And makes things even slower than * the calendar module. */ #ifndef HAVE_EXTERNAL_TIMEZONE #define timezone 0 #endif #define WITH_ZONE(RETURNTYPE, FUNCTION, ARGUMENTS, CALL ) \ static RETURNTYPE FUNCTION##_zone ARGUMENTS \ { \ RETURNTYPE res; \ int reset = 0; \ char *old_zone = NULL; \
-
if(
x->tm
_
zone
)
\
+
if(
GET_ZONE(
x
)
) \
{ \ reset = 1; \ old_zone = getenv("TZ"); \
-
setenv("TZ",
x->tm
_
zone
, 1 );
\
+
setenv("TZ",
GET_ZONE(
x
)
, 1 ); \
tzset(); \
-
x->tm
_
gmtoff
=
timezone; \
+
SET_GMTOFF(
x
,
timezone
)
; \
} \ \ res = FUNCTION CALL; \ \ if( reset ) \ { \ if( old_zone ) \ setenv("TZ", old_zone, 1 ); \ else \ unsetenv( "TZ" ); \
pike.git/src/builtin.cmod:367:
int post_sum = 1; switch( flag ) { case 'O': push_text("System.TM("); post_sum = 1; /* fallthrough */ case 's': f_TM_asctime(0); push_text("\n");
-
if( THIS->t
.tm_zone
)
+
if(
GET_ZONE(&(
THIS->t
))
)
{ push_text(" ");
-
push_text( THIS->t
.tm_zone
);
+
push_text(
GET_ZONE(&(
THIS->t
))
);
f_add( 2 ); } else push_text(""); f_replace( 3 ); break; case 'd': f_TM_unix_time(0); break; default:
pike.git/src/builtin.cmod:415:
} Pike_error("Does not know how to cast to %s\n", to->str ); } /*! @decl string zone *! *! The timezone of this structure */ PIKEFUN string `zone() { FIX_THIS();
-
if( THIS->t
.tm_zone
)
-
push_text( THIS->t
.tm_zone
);
+
if(
GET_ZONE(&(
THIS->t
))
)
+
push_text(
GET_ZONE(&(
THIS->t
))
);
else push_undefined(); } /*! @decl int gmtoff *! The offset from GMT for the time in this tm-struct */ PIKEFUN int `gmtoff() { FIX_THIS();
-
push_int( THIS->t
.tm_gmtoff
);
+
push_int(
GET_GMTOFF(&(
THIS->t
))
);
} /* Setting the zone does not work, so.. */ /* PIKEFUN string `zone=(string x) { */ /* if( THIS->set_zone ) */ /* free_string( THIS->set_zone ); */ /* THIS->set_zone = x; */ /* MODIFY( tm_zone = x->str ); */ /* x->refs++; */
pike.git/src/builtin.cmod:449:
/*! @decl int(0..1) localtime( int time ) *! Initialize the struct tm to the local time for the specified *! unix time_t. */ PIKEFUN int(0..1) localtime( int _t ) { time_t t = _t; struct tm *res = localtime_zone( &t, &THIS->t ); /* These are supposedly correctly by localtime_zone. */
-
res->tm
_
gmtoff
=
THIS->t
.tm_gmtoff
;
-
res->tm
_
zone
=
THIS->t
.tm_zone
;
+
SET_GMTOFF(
res
, GET
_
GMTOFF(&(
THIS->t
)))
;
+
SET_ZONE(
res
, GET
_
ZONE(&(
THIS->t
)))
;
if( !res ) RETURN 0; THIS->t = *res; THIS->modified = 1; RETURN 1; } /*! @decl int(0..1) gmtime( int time )
pike.git/src/builtin.cmod:522:
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";
+
SET_ZONE(
t
,
"UTC"
)
;
else { add_ref(timezone); THIS->set_zone = timezone;
-
t->tm
_
zone
=
timezone->str;
+
SET_ZONE(
t
,
timezone->str
)
;
} THIS->unix_time = mktime_zone( t ); } INIT { THIS->set_zone = 0; THIS->modified = 0; } EXIT { if( THIS->set_zone ) free_string( THIS->set_zone ); } } #undef FIX_THIS #ifdef STRUCT_TM_HAS___TM_GMTOFF #undef tm_zone
-
+
#undef tm_gmtoff
#endif #endif /*! @endmodule */ /*! @decl array(array(int|string|type)) describe_program(program p) *! @belongs Debug *! *! Debug function for showing the symbol table of a program. *!