101 |
101 |
102 Timezones handling game me headaches at first. I finally concluded that the best way (for me !) to handle |
102 Timezones handling game me headaches at first. I finally concluded that the best way (for me !) to handle |
103 TZ data was to store every datetime value in GMT timezone. |
103 TZ data was to store every datetime value in GMT timezone. |
104 As far as I know, there is no easy way to know the user's timezone from his request settings. So you can: |
104 As far as I know, there is no easy way to know the user's timezone from his request settings. So you can: |
105 - store this timezone in user's profile, |
105 - store this timezone in user's profile, |
106 - define a static server's timezone :-/ |
106 - define a static server's timezone |
|
107 - create and register a ServerTimezoneUtility to handle server default timezone. |
107 |
108 |
108 My current default user's timezone is set to 'Europe/Paris' ; you should probably update this setting in |
109 My current default user's timezone is set to 'Europe/Paris' ; you should probably update this setting in |
109 'timezone.py' if you are located elsewhere. |
110 'timezone.py' if you are located elsewhere. |
110 |
111 |
111 >>> from ztfy.utils import timezone |
112 >>> from ztfy.utils import timezone |
112 >>> timezone.tztime(ddate) |
113 >>> timezone.tztime(ddate) |
113 datetime.datetime(2008, 3, 8, 20, 13, 20, tzinfo=<DstTzInfo 'Europe/Paris' CET+1:00:00 STD>) |
114 datetime.datetime(2008, 3, 8, 19, 13, 20, tzinfo=<StaticTzInfo 'GMT'>) |
114 |
115 |
115 'gmtime' function can be used to convert a datetime to GMT: |
116 'gmtime' function can be used to convert a datetime to GMT: |
116 |
117 |
117 >>> timezone.gmtime(now) |
118 >>> timezone.gmtime(now) |
118 datetime.datetime(2008, 3, 8, 19, 13, 20, tzinfo=<StaticTzInfo 'GMT'>) |
119 datetime.datetime(2008, 3, 8, 19, 13, 20, tzinfo=<StaticTzInfo 'GMT'>) |