GithubHelp home page GithubHelp logo

push2dream / js-iso8601 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from csnover/js-iso8601

0.0 2.0 0.0 248 KB

Enhances Date.parse to support ES5 ISO-8601 strings in all environments.

JavaScript 91.23% HTML 8.77%

js-iso8601's Introduction

Universal JavaScript Date.parse for ISO 8601

ECMAScript revision 5 adds native support for simplified ISO 8601 dates in the Date.parse method, but some browsers currently on the market (Safari 5-, IE 8-, Firefox 3.6-) do not support it. This is a simple shim for Date.parse that adds support for parsing ES5 simplified ISO 8601 strings to all browsers.

If you are attempting to parse date strings coming from non-ES5-conformant backends, please consider using the non-conformant edition.

Caveats

  1. This library strictly implements the simplified ISO 8601 date time string format specified in the ES5 Errata (§15.9.1.15) and will not parse ISO 8601 variants that would otherwise be considered valid under ISO 8601:2004(E).
  2. Creating a new date using the new Date(dateString) form will not be fixed by this shim.
  3. ES5 §15.9.4.2 states that parsing for Date Time String Format must occur prior to any implementation-specific date format parsing; therefore, this JavaScript implementation will always be used in lieu of native browser support for parsing the simplified ISO 8601 date format.

Unit tests

By default, the unit tests are configured only to test the JavaScript fallback portion of the script, which means your browser’s native Date.parse implementation will not be used. Add “?useNativeDateParse” to the URL to run unit tests that will use the browser’s native implementation (for browser compliance testing purposes).

Note: You must checkout using git clone --recursive in order for unit tests to function.

License

© 2011 Colin Snover. MIT Licensed.

js-iso8601's People

Contributors

csnover avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.