returning results from function

N

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top