Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.python

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 11-11-2010, 09:10 PM
Stefan Sonnenberg-Carstens
Guest
 
Posts: n/a
Default Re: returning results from function

Am 11.11.2010 22:16, schrieb Neil Berg:
> Hi Python community,
>
> In a main script, I pass the year (yr), month (mo), day (dy) and hour(hr) into the utc_to_local function (pasted below) which converts that date and time into local standard time. I am passing several dates and times into this function and would like to work with the "returned" loc_y/m/d/h values, but no output is visibly seen when I run the main script. I want the "return" command to just return the values to me in the main script so I can work with them! Any help is appreciated.
>
> Thanks in advance,
> Neil
>
> _________
> Mac OS X 10.6.4
> Python 2.6
> _________
>
> from datetime import datetime
> from pytz import timezone
> import pytz
>
> def utc_to_local(yr,mo,dy,hr):
> fmt = '%Y-%m-%d %H %Z'
> utc = pytz.utc
> local = pytz.timezone("US/Pacific")
> utc_dt = datetime(yr,mo,dy,hr, tzinfo=utc)
> loc_dt = utc_dt.astimezone(local) # local date YY-MM-DD HR TZ
> #print utc_dt.strftime(fmt), " = ", loc_dt.strftime(fmt)
>
> loc_y = loc_dt.year # local year
> loc_m = loc_dt.month # local month
> loc_d = loc_dt.day # local day
> loc_h = loc_dt.hour # local hour
>
> return loc_y, loc_m, loc_d, loc_h
>

Could you please be so nice and share the relevant parts of your main
script with us ?

Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 12:10 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.