Ticket #2778 (closed feature: fixed)

Opened 3 years ago

Last modified 3 years ago

add ISO date parsing and toISOString for dates

Reported by: tschaub Owned by:
Priority: minor Milestone: 2.10 Release
Component: BaseTypes Version: 2.9
Keywords: Cc:
State: Complete

Description

The  ECMA-262 (v5) spec defines a toISOString method on date objects. It also specifies the format for the Date.parse method (previously unspecified). The string format follows  RFC 3339, a profile of  ISO 8601 for timestamps on the Internet.

Browsers are beginning to implement ECMA-262. Firefox, for example, currently (3.6.8) implements toISOString and the specified Date.parse format. Safari (5.0) supports toISOString but does not parse the same format for Date.parse. Chrome is similar. IE is hopeless.

We can provide a cross-browser implementation of toISOString and Date.parse and default to the native methods if available.

Attachments

2778.patch Download (10.7 KB) - added by tschaub 3 years ago.
date string parsing

Change History

Changed 3 years ago by tschaub

date string parsing

Changed 3 years ago by tschaub

  • state set to Review

Tests pass in FF 3.6, Safari 5, Chrome 5, and IE 6. Thanks for any review.

Changed 3 years ago by ahocevar

  • state changed from Review to Commit

One of the most impressive patches I have ever seen. Huge test coverage, and a regular expression which I hope you did not make up on your own. Otherwise I should stop writing code :-).

Please commit.

Changed 3 years ago by tschaub

The regex is my own :) But the process of getting there was iterative. Thanks for the review.

Changed 3 years ago by tschaub

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [10630]) Adding OpenLayers.Date utility functions to parse and serialize dates. The date string format parsed complies with ECMA-262 (v5) section 15.9.1.15, derived from the profile of ISO 8601 for date and time on the Internet ( http://tools.ietf.org/html/rfc3339). Where available (and functional) the native date.toISOString and Date.parse methods will be used. r=ahocevar (closes #2778)

Note: See TracTickets for help on using tickets.