Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,18 +381,18 @@
format : "DD/MM/YYYY",
_formatLookup : [
['DD', "\\d{2}"],
['D' , "\\d{1}|\\d{2}"],
['D' , "(\\d{1}|\\d{2})"],
['MM', "\\d{2}"],
['M' , "\\d{1}|\\d{2}"],
['M' , "(\\d{1}|\\d{2})"],
['YYYY', "\\d{4}"],
['YY', "\\d{2}"],
['A', "[AM|PM]"],
['hh', "\\d{2}"],
['h', "\\d{1}|\\d{2}"],
['h', "(\\d{1}|\\d{2})"],
['mm', "\\d{2}"],
['m', "\\d{1}|\\d{2}"],
['m', "(\\d{1}|\\d{2})"],
['ss', "\\d{2}"],
['s', "\\d{1}|\\d{2}"],
['s', "(\\d{1}|\\d{2})"],
['ZZ',"[-|+]\\d{4}"],
['Z', "[-|+]\\d{2}:\\d{2}"]
],
Expand Down
3 changes: 2 additions & 1 deletion test/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
source :rubygems
gem 'sinatra'
gem 'rack-contrib'
gem 'rack-contrib'
gem 'json'
2 changes: 2 additions & 0 deletions test/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
GEM
remote: http://rubygems.org/
specs:
json (1.5.3)
rack (1.4.1)
rack-contrib (1.1.0)
rack (>= 0.9.1)
Expand All @@ -16,5 +17,6 @@ PLATFORMS
ruby

DEPENDENCIES
json
rack-contrib
sinatra
11 changes: 10 additions & 1 deletion test/unit/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@
{ input : "2011/6/2", format : "YYYY/M/D" },
{ input : "2011/6/20", format : "YYYY/M/D" },
{ input : "2011/6/20 4PM", format : "YYYY/M/D hA" },
{ input : "2011/6/20 4PM", format : "YYYY/M/D hhA" },
{ input : "2011/6/20 12PM", format : "YYYY/M/D hA" },
{ input : "12PM", format : "hA" },
{ input : "12:30 PM", format : "h:m A" },
Expand All @@ -175,10 +174,20 @@
{ input : "12:05:30 +0400", format : "hh:mm:s ZZ" },
{ input : "12:05:30 -0400", format : "hh:mm:ss ZZ" }
];

var badtimes = [
{ input : "2011", format: "D/M/YYYY" },
{ input : "2011/6/20 4PM", format : "YYYY/M/D hhA" }
];

_.each(testtimes, function(t) {
ok(Dataset.types.time.test(t.input, {format : t.format}), t.input);
ok(Dataset.types.time.coerce(t.input, {format:t.format}).valueOf(), moment(t.input, t.format).valueOf());
});

_.each(badtimes, function(t) {
ok(!Dataset.types.time.test(t.input, {format : t.format}), t.input);
});
});

test("Check date type", function() {
Expand Down