Permalink
Browse files

added am/pm to regex, but nothing else

  • Loading branch information...
1 parent 5381dc5 commit b73c2e5246d30ad1ce5df359623eead59ef7a596 @zackdever committed Sep 11, 2012
Showing with 7 additions and 3 deletions.
  1. +0 −1 README.md
  2. +7 −2 time.js
View
@@ -38,7 +38,6 @@ If you fancy it, you can use safely drop the 'new'.
Converts Time into the next corresponding JavaScript Date.
// assume it's 3:15 pm Aug 10
- Time('3:15').nextDate() // 3:15 pm Aug 10
Time('415').nextDate() // 4:15 pm Aug 10
Time('2').nextDate() // 2:00 am Aug 11
View
@@ -1,11 +1,15 @@
(function() {
+ // TODO support military time
+ // TODO make military time optional
+ // TODO make british delineation optional
+
// play nice with both node.js and browser
if (typeof module !== 'undefined' && module.exports) module.exports = Time;
else window.Time = Time;
- // what you might expect to be a valid time e.g. 2, 2:00, 12:18, 4.23
- Time.re = /^(10|11|12|[1-9])(?::|\.)?([0-5][0-9])?$/;
+ // what you might expect to be a valid time e.g. 2, 2:00a, 12:18, 4.23 p.m.
+ Time.re = /^(10|11|12|[1-9])(?::|\.)?([0-5][0-9])?(a|p.?(m.?)?)?$/;
/*
* Time constructor works with(out) 'new'
@@ -35,6 +39,7 @@
/*
* Find the next immediate corresponding Date.
+ *
* Assume it's 3:15 pm Aug 10:
* Time('3:15').nextDate() // 3:15 pm Aug 10
* Time('415').nextDate() // 4:15 pm Aug 10

0 comments on commit b73c2e5

Please sign in to comment.