« first day (1301 days earlier)      last day (1100 days later) » 

2:40 PM
@OliverSalzburg any idea how to parse a datetime like this: '1989-01-01T00:00:00+02:00'
 
@IvoFlipse In Cobol?
 
preferably :P
 
:D
Seriously though, what language? A generic algorithm would be asking a bit much
 
Python
Actually the only problem I'm having is with the +02:00 the time zone offset
 
Looks like a standard ISO date string
In JS you'd just wrap in new Date()
I would expect something similar in Python
 
2:45 PM
I'm using some function to create a date object from the string: datetime.datetime.strptime('1989-01-01T00:00:00+02:00',"%Y-%m-%dT%H:%M:%S")
but it needs a format string, to tell it how to parse it
and that's missing something for that F-ing +02:00
I've considered simply ignoring the whole time part, but I was trying to do it "the right way"
 
If it can print it, it should be able to parse it
@IvoFlipse Seems like you need %z
 
yeah, which seems to be deprecated
ValueError: 'z' is a bad directive in format '%Y-%m-%dT%H:%M:%S%z'
For a naive object, the %z and %Z format codes are replaced by empty strings.

For an aware object:

%z
utcoffset() is transformed into a 5-character string of the form +HHMM or -HHMM, where HH is a 2-digit string giving the number of UTC offset hours, and MM is a 2-digit string giving the number of UTC offset minutes. For example, if utcoffset() returns timedelta(hours=-3, minutes=-30), %z is replaced with the string '-0330'.

%Z
If tzname() returns None, %Z is replaced by an empty string. Otherwise %Z is replaced by the returned value, which must be a string.
 
144
Q: How to parse ISO formatted date in python?

Alexander ArtemenkoI need to parse strings like "2008-09-03T20:56:35.450686Z" into python's datetime type. I have found only strptime in python 2.5 std lib, but it is not so convenient. What is the best way to do this?

What about that?
Long story short: No, I have no clue :D
 
lol
it uses an external library
which I don't mind
but I'm doing this for a Udacity class
I'll just skip parsing that :P
its a string after all
 
3:02 PM
You can't skip it, it's important :P
Depending on what you expect your result to be
 
lol
well actually they only care about the year
so I'm already overdoing it
 
Oh
Well, but maybe that's the catch
 
There's nice cases like this one: {1998-01-01T00:00:00+02:00|1999-01-01T00:00:00+02:00}
 
Know what I mean?
 
yeah that's what the strptime function is for
its like: interpret this string as a datetime object
 
3:08 PM
I mean, it'll be a different year depending on the timezone
 
the regular datetime requires year, month, day
well and time obviously :P
lol I made a very hacky solution and it worked :P
I just checked if I ever got a datetime like the one above, it should check if the first char is { and if so, take date[1:5] else date[:4]
I wasted way more time on that than necessary
 

« first day (1301 days earlier)      last day (1100 days later) »