How should I determine the timedelta offset..is it based on GMT...?

On Nov 14, 10:45 pm, Simo Salminen <[email protected]> wrote:
> Forget the method first_sunday:
> def first_sunday(d):
>     while 1:
>         if d.weekday() == 6: # sunday
>             return d
>         d -= datetime.timedelta(days=1)
>
> On Nov 14, 7:41 pm, Simo Salminen <[email protected]> wrote:
>
> > Not really related to this, but I had following problem: how to
> > convert local finnish time zone to utc. I could not really find
> > solution to this. Using python time library does not work because
> > time.tzset does not work on app engine. In the end I decided to build
> > solution by hand, only working for one timezone. If anyone knows
> > better solution, let me know.
>
> > The code:
> > def utc_offset(dt, country_code):
> >     """"Return utc_offset in hours for given time. This can be wrong
> > for times
> >     during the change period of summer<->winter (between 3 and 4
> > am)."""
> >     assert country_code == "fi", "Only finland is supported"
>
> >     year = dt.year
>
> >     # start and end of summer time in finland
> >     start = datetime.datetime(year, 3, 31, 3, 0)
> >     end = datetime.datetime(year, 10, 31, 3, 0)
>
> >     start_sunday = first_sunday(start)
> >     end_sunday = first_sunday(end)
>
> >     if dt > start_sunday and dt < end_sunday:
> >         return 3
> >     else:
> >         return 2
>
> > On Nov 14, 8:47 am, 风笑雪 <[email protected]> wrote:
>
> > > You can create an timezone object:
>
> > >http://groups.google.com/group/google-appengine-python/browse_thread/...
>
> > > 2009/11/14 deostroll <[email protected]>:
>
> > > > Hi,
>
> > > > I was just wondering how you can get the exact IST time...? When it
> > > > comes to the cloud how is all this managed?
>
> > > > --deostroll
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google 
> > > > Groups "Google App Engine" group.
> > > > To post to this group, send email to [email protected].
> > > > To unsubscribe from this group, send email to 
> > > > [email protected].
> > > > For more options, visit this group 
> > > > athttp://groups.google.com/group/google-appengine?hl=.

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=.


Reply via email to