Skip to content

A simple utility to check if a string is an ISO-compliant date.

Notifications You must be signed in to change notification settings

honeinc/is-iso-date

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

is-iso-date Build Status

is-iso-date is a simple utility to check if a string is an ISO-compliant date.

Install

$ npm install is-iso-date

Usage

var isISODate = require( 'is-iso-date' );

console.log( isISODate( '2015-02-21T00:52:43.822Z' ) ); // true
console.log( isISODate( '2015-02-21T00:52:43.822' ) );  // false
console.log( isISODate( '2015-02-21T00:52:43Z' ) );     // true
console.log( isISODate( '2015-02-21T00:52:43' ) );      // false
console.log( isISODate( '2015-02-21T00:52Z' ) );        // true
console.log( isISODate( '2015-02-21T00:52' ) );         // false
console.log( isISODate( '2015-02-21T00Z' ) );           // false

Reference

This is basically just the regexp from this StackOverflow discussion wrapped in a tiny library with some tests: http:https://stackoverflow.com/questions/3143070/javascript-regex-iso-datetime

About

A simple utility to check if a string is an ISO-compliant date.

Resources

Stars

Watchers

Forks

Packages

No packages published