[K12OSN] OT: scripting help

Vern Ceder vceder at canterburyschool.org
Wed May 16 03:05:55 UTC 2007


Assuming that value is a datetime object, which it looks like, you could 
do something like this:

return (value + timedelta(hours=4)).strftime('%Y%m%dT%H%M%S')

depending on how it's imported, you might need to use datetime.timedelta 
instead of timedelta...

Cheers,
Vern Ceder

Peter Scheie wrote:
> I'm no python wizard, but it seems to me that problem is that strftime 
> is a  string formatting method, and you want to add an integer to that 
> string, which doesn't make sense to python.  But there might be some 
> other time function you could use in place of that line.
> 
> Petre
> 
> Peter Hartmann wrote:
>> I am trying to hack schooltool to export an ical in our timezone
>> instead of UTC.  I'm hoping that this is trivial....   in icalendar.py
>> i'm trying to alter this line to add 4 hours.
>>
>> return value.strftime('%Y%m%dT%H%M%S')
>>
>> I tried this:
>>
>> return value.strftime('%Y%m%dT%H+4%M%S')
>>
>> but in the resluting ical file it gave me this:
>>
>> DTSTART:20051204T14+40000Z
>>
>> It printed +4 instead of doing the math.  can this be done on one line?
>>
>> Thanks,
>> Peter
>>
>> _______________________________________________
>> K12OSN mailing list
>> K12OSN at redhat.com
>> https://www.redhat.com/mailman/listinfo/k12osn
>> For more info see <http://www.k12os.org>
>>
> 
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>

-- 
This time for sure!
    -Bullwinkle J. Moose
-----------------------------
Vern Ceder, Director of Technology
Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804
vceder at canterburyschool.org; 260-436-0746; FAX: 260-436-5137




More information about the K12OSN mailing list