2004-04-01
2004-04-01 15:44:56 by Henrik Grubbström (Grubba) <grubba@grubba.org>
-
69a342f68094677a6f73ee47237d0c4cd91fecb9
(37 lines)
(+14/-23)
[
Show
| Annotate
]
Branch: 7.9
Fixed bug in localtime() and updated documentation.
Rev: src/builtin_functions.c:1.535
2:
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
- || $Id: builtin_functions.c,v 1.534 2004/03/30 12:50:56 grubba Exp $
+ || $Id: builtin_functions.c,v 1.535 2004/04/01 15:44:56 grubba Exp $
*/
#include "global.h"
- RCSID("$Id: builtin_functions.c,v 1.534 2004/03/30 12:50:56 grubba Exp $");
+ RCSID("$Id: builtin_functions.c,v 1.535 2004/04/01 15:44:56 grubba Exp $");
#include "interpret.h"
#include "svalue.h"
#include "pike_macros.h"
4304: Inside #if defined(HAVE_LOCALTIME)
*! @member int(0..1) "isdst"
*! Is daylight savings time.
*! @member int "timezone"
- *! Offset from UTC.
+ *! Offset from UTC, including daylight savings time adjustment.
*! @endmapping
*!
*! An error is thrown if the localtime(2) call failed on the system.
4312: Inside #if defined(HAVE_LOCALTIME)
*! e.g. Windows doesn't handle a negative @[timestamp].
*!
*! @note
- *! The field @expr{"timezone"@} may not be available on all platforms.
+ *! Prior to Pike 7.5 the field @expr{"timezone"@} was sometimes not
+ *! present, and was sometimes not adjusted for daylight savings time.
*!
*! @seealso
*! @[Calendar], @[gmtime()], @[time()], @[ctime()], @[mktime()]
4332: Inside #if defined(HAVE_LOCALTIME)
pop_n_elems(args);
encode_struct_tm(tm);
- #ifdef STRUCT_TM_HAS_GMTOFF
+
push_text("timezone");
-
+ #ifdef STRUCT_TM_HAS_GMTOFF
push_int(-tm->tm_gmtoff);
- f_aggregate_mapping(20);
- #else
- #ifdef STRUCT_TM_HAS___TM_GMTOFF
- push_text("timezone");
+ #elif defined(STRUCT_TM_HAS___TM_GMTOFF)
push_int(-tm->__tm_gmtoff);
- f_aggregate_mapping(20);
+ #elif defined(HAVE_EXTERNAL_TIMEZONE)
+ /* Assume dst is one hour. */
+ push_int(timezone - 3600*tm->tm_isdst);
#else
- #ifdef HAVE_EXTERNAL_TIMEZONE
- push_text("timezone");
- push_int(timezone);
- f_aggregate_mapping(20);
- #else
- f_aggregate_mapping(18);
+ /* Assume dst is one hour. */
+ push_int(-3600*tm->tm_isdst);
#endif
- #endif
- #endif
+ f_aggregate_mapping(20);
}
#endif
4382: Inside #if defined(HAVE_GMTIME)
struct tm *current_tm;
int loop_cnt = 0;
- #if 0 /* The dst offset is part of tz. */
- /* Assume dst is one hour. */
- target_tm->tm_hour -= target_tm->tm_isdst;
- #endif /* 0 */
-
+
/* This loop seems stable, and usually converges in two passes.
* The loop counter is for paranoia reasons.
*/