File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,6 +89,37 @@ extern int ftime();
8989static int floatsleep Py_PROTO ((double ));
9090static double floattime Py_PROTO (( ));
9191
92+ #ifdef macintosh
93+ /* Our own timezone. We have enough information to deduce whether
94+ ** DST is on currently, but unfortunately we cannot put it to good
95+ ** use because we don't know the rules (and that is needed to have
96+ ** localtime() return correct tm_isdst values for times other than
97+ ** the current time. So, we cop out and only tell the user the current
98+ ** timezone.
99+ */
100+ static long timezone ;
101+
102+ static void
103+ initmactimezone ()
104+ {
105+ MachineLocation loc ;
106+ long delta ;
107+
108+ ReadLocation (& loc );
109+
110+ if (loc .latitude == 0 && loc .longitude == 0 && loc .u .gmtDelta == 0 )
111+ return ;
112+
113+ delta = loc .u .gmtDelta & 0x00FFFFFF ;
114+
115+ if (delta & 0x00800000 )
116+ delta |= 0xFF000000 ;
117+
118+ timezone = - delta ;
119+ }
120+ #endif /* macintosh */
121+
122+
92123static PyObject *
93124time_time (self , args )
94125 PyObject * self ;
@@ -430,6 +461,11 @@ inittime()
430461 ins (d , "tzname" ,
431462 Py_BuildValue ("(zz)" , wintername , summername ));
432463 }
464+ #else
465+ #ifdef macintosh
466+ initmactimezone ();
467+ ins (d , "timezone" , PyInt_FromLong (timezone ));
468+ #endif /* macintosh */
433469#endif /* HAVE_TM_ZONE */
434470#endif /* !HAVE_TZNAME */
435471 if (PyErr_Occurred ())
You can’t perform that action at this time.
0 commit comments