Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop 348 date parse 1st regression #84

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Native/Date.js
Expand Up @@ -429,7 +429,7 @@ var build = function(format){

if (year != null) handle.call(date, 'y', year); // need to start in the right year
if ('d' in bits) handle.call(date, 'd', 1);
if ('m' in bits || 'b' in bits || 'B' in bits) handle.call(date, 'm', 1);
if ('m' in bits || bits['b'] || bits['B']) handle.call(date, 'm', 1);

for (var key in bits) handle.call(date, key, bits[key]);
return date;
Expand Down
11 changes: 11 additions & 0 deletions Specs/Native/Date.js
Expand Up @@ -424,6 +424,17 @@ describe('Date.parse', {
value_of(Date.parse(d.format('%B %d %Y'))).should_be(d);

Date.prototype.clearTime = clearTime;
},

'should parse 1st into first day of month': function(){
var d = new Date();
value_of(Date.parse('1st')).should_be(new Date(d.getFullYear(), d.getMonth(), 1, 0, 0, 0));
},

'should parse 1st, Oct 31 and 31 Oct correctly': function(){
value_of(Date.parse('1st').set({month: 8, year: 2010}).format('%m/%d/%Y')).should_be('09/01/2010');
value_of(Date.parse('31 Oct').set('year', 2010).format('%m/%d/%Y')).should_be('10/31/2010');
value_of(Date.parse('Oct 31').set('year', 2010).format('%m/%d/%Y')).should_be('10/31/2010');
}

});