python - Unable to get proper timestamp ranges -
I hope to generate many limitations in between:
18:00 (EST ) With the interval size of
2.2 seconds
and 400 seconds later on October 6, 2014.
Getting start and end dates:
When I do the following:
start_time = datetime.datetime (year = 2014, month = 10 , = 6, hours = 18, tzinfo = pytz.timezone ('US / Eastern')) end_time = start_time + datetime.timedelta (seconds = 400)
Some seem unsuccessful:
start_time.isoformat () returns
'2014-10-06T18: 06: 40-04: 56' < Li>
and_times.isoformat () returns
'2014-10-06 to 18: 06: 40-04: 56'
Note that the time zone is offset for the above two time ranges Are:
-04: 56 (4 hours and 56 minutes) Even if EST is behind UTC is 5 hours ? Getting the deadline:
On the move, if I try to get many time limits between these two dates then each
2.2 seconds (I.e.
2200 ms ):
ts = pd.date_range (start = start_time, end = end_time, freq = '2200L')
I get:
& gt; Ts [0] timestamp ('2014-10-06 18: 56: 00-0400', tz = 'US / Eastern', offset = '2200L')
Or in other words :
& gt; Ts [0] .isoformat () '2014-10-06T18: 56: 00-04: 00'
Whatever is not understood (note that time is
18 : 56 , even if I get the range between
18:00 and
18:06:40 (i.e.
400 ) I was tired of tackling Python's odd date time after
18:00
Implementation (especially regarding timezone), and has started using crsmithdev.com/arrow. A solution using this script:
import arrow start_time = arrow.get (2014, 10, 6, tzinfo = 'US / Eastern') end_time = start_time.replace (seconds = 400) print start_time.isoformat () print end_time.isoformat () # Optionally start_time = arrow.get ('2014-10-06T18: 00: 00.000- 04:00') end_time = start_time.replace (seconds = 400) print start_time.isoformat () print end_time.isoformat () # from an arrow object Get datetime start_time_dt = start_time.datetime
Comments
Post a Comment