Hi,
So, in dealing with the Google Data API most dates use the format above. Here is a regular expression to decompose it:
1 2 3 4 5 6 7 8 9 10 11 12 13 | var date:String = "2010-12-12T09:54:35.002Z"; var exp:RegExp = /(\d\d\d\d)([- \/.])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])T([0-2][0-9]):([0-5][0-9]):([0-5][0-9]).([0-9]{3})Z/i; var res:Object = exp.exec(date); // year res[1] // month res[3] // day res[4] // hour res[5] // minute res[6] // seconds res[7] // milliseconds res[8] |
Now remember that the constructor for the Date object is quite a pain. It considers Januaray to be month 0, and the first day of the month to be the zero’th day of the month.. With this in mind, you can construct the Date object.
1 | var time:Date = new Date(res[1], res[3] - 1, res[4] - 1, res[5], res[6], res[7], res[8]); |
Now, switch to the time-zone of the user..
1 | time.minutes -= time.getTimezoneOffset(); |
That’s it folks!