# [Tutor] time challange

nephish nephish at xit.net
Thu Sep 22 18:55:54 CEST 2005

```paul brian wrote:

>You are fairly close
>
>
>
>>>>t1 = today()
>>>>t1
>>>>
>>>>
><DateTime object for '2005-09-22 00:00:00.00' at 11656e0>
>
>
>>>>t2 = today() + RelativeDateTime(hours=20)
>>>>t2
>>>>
>>>>
><DateTime object for '2005-09-22 20:00:00.00' at 1165760>
>
>
>>>>t3 = t2 - t1
>>>>t3.hours
>>>>
>>>>
>20.0
>
>
>>>>slice = t3/20
>>>>slice
>>>>
>>>>
><DateTimeDelta object for '01:00:00.00' at 116cc50>
>
>t3 is a "Delta" - that is an abstract representation
>of time - it is not the 20 hours since midnight, just 20 hours
>at any time in the universe.
>slice is just 1/20th of that same abstract time. But because of the munificence
>of Marc we can add that abstract hour to a real fixed time (ignoring
>Einstein of course)
>
>
>
>>>>t1 + slice
>>>>
>>>>
><DateTime object for '2005-09-22 01:00:00.00' at 11655e0>
>
>And so that is a "real" datetime 1/20th of the way forward from t1
>
>so a simple loop will get you your 20 evenly spaced time periods,
>which is what i think you were asking for.
>
>cheers
>
>
>
>On 9/22/05, nephish <nephish at xit.net> wrote:
>
>
>>Hey there,
>>
>>i use mx.DateTime.RelativeDateTimeDiff to get the difference between
>>date_x and date_y.
>>what i need to do divide this amount of time into 20 different times
>>that spaced out between the date_x and the date_y.
>>
>>so if the difference between date_x and date_y is 20 hours, i need 20
>>DateTimes that are one hour apart from each other. If the difference is
>>40 minutes, i need the 20 DateTimes to be spaced out 2 minutes from each
>>other..
>>
>>what would be a way to pull this off? i have looked at the docs for
>>mxDateTime
>>http://www.egenix.com/files/python/mxDateTime.html
>>and there seems to be a divide operation, but i dont quite know what it
>>with the deltas.
>>
>>anyone have a good start point?
>>
>>thanks
>>shawn
>>_______________________________________________
>>Tutor maillist  -  Tutor at python.org
>>http://mail.python.org/mailman/listinfo/tutor
>>
>>
>>
>
>
>--
>--------------------------
>Paul Brian
>m. 07875 074 534
>t. 0208 352 1741
>
>
>
YES !
that is what i needed. This is great.
i think i understand your steps ok, but you lost me with the munificence
of Marc. i never got to take physics. All the same, thanks so much

shawn
```