Android, Webkit and Date parsing

March 15, 2011

Here’s a thing.

You know how you’ve always felt a bit uneasy when you’ve passed a string into javascript’s new Date(), even when you know it’s in perfectly respectable ISO format?

Well it doesn’t work at all on my phone (Android 2.1 running WebKit 3.1).

Bummer.

Give new Date() a timestamp instead. Here’s some dirty python to generate just that:

    import time
    return int(time.mktime(the_date.timetuple()) * 1000)

We’ll fret about timezones later

Advertisement

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.