From 9ceefc692fc36ca96afbb76aed1683074179b2c8 Mon Sep 17 00:00:00 2001 From: Henning Bopp Date: Sun, 5 Feb 2017 13:52:45 +0100 Subject: [PATCH 1/4] Added %n for Date.format + Spec fixes mootools/mootools-more#1342 --- Source/Types/Date.js | 1 + Specs/Types/Date.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Types/Date.js b/Source/Types/Date.js index 69b1bcad..d67eb0e5 100644 --- a/Source/Types/Date.js +++ b/Source/Types/Date.js @@ -235,6 +235,7 @@ Date.implement({ case 'L': return pad(d.get('ms'), 3); case 'm': return pad((d.get('mo') + 1), 2); case 'M': return pad(d.get('min'), 2); + case 'n': return (d.get('mo') + 1); case 'o': return d.get('ordinal'); case 'p': return Date.getMsg(d.get('ampm')); case 's': return Math.round(d / 1000); diff --git a/Specs/Types/Date.js b/Specs/Types/Date.js index 2f30dbc1..5bd09138 100644 --- a/Specs/Types/Date.js +++ b/Specs/Types/Date.js @@ -421,9 +421,12 @@ describe('Date', function(){ it('should return the month number as two digits', function(){ expect(d.format('%m')).toEqual('11'); }); - it('should return the minutes as two digits', function(){ + it('should return the minutes as two digits', function(){ expect(d.format('%M')).toEqual('02'); }); + it('should return the month as one digit', function(){ + expect(d.format('%n')).toEqual('2'); + }); it('should return the ordinal, and should be the same as .getOridnal', function(){ expect(d.format('%o')).toEqual(d.get('ordinal')); }); From 46bbd6512189d9bafe6d5a9ff6d296a9f8ed2131 Mon Sep 17 00:00:00 2001 From: Henning Bopp Date: Sun, 5 Feb 2017 13:59:31 +0100 Subject: [PATCH 2/4] fixing code style again ;) --- Specs/Types/Date.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Specs/Types/Date.js b/Specs/Types/Date.js index 5bd09138..cc1a5c41 100644 --- a/Specs/Types/Date.js +++ b/Specs/Types/Date.js @@ -421,10 +421,10 @@ describe('Date', function(){ it('should return the month number as two digits', function(){ expect(d.format('%m')).toEqual('11'); }); - it('should return the minutes as two digits', function(){ + it('should return the minutes as two digits', function(){ expect(d.format('%M')).toEqual('02'); }); - it('should return the month as one digit', function(){ + it('should return the month as one digit', function(){ expect(d.format('%n')).toEqual('2'); }); it('should return the ordinal, and should be the same as .getOridnal', function(){ From 9ac83a2324a9c550b555d3aaa59caf0fb6df56ea Mon Sep 17 00:00:00 2001 From: Henning Bopp Date: Sun, 5 Feb 2017 14:07:19 +0100 Subject: [PATCH 3/4] read before you commit... --- Specs/Types/Date.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Specs/Types/Date.js b/Specs/Types/Date.js index cc1a5c41..6e7ede61 100644 --- a/Specs/Types/Date.js +++ b/Specs/Types/Date.js @@ -425,7 +425,7 @@ describe('Date', function(){ expect(d.format('%M')).toEqual('02'); }); it('should return the month as one digit', function(){ - expect(d.format('%n')).toEqual('2'); + expect(d.format('%n')).toEqual('11'); }); it('should return the ordinal, and should be the same as .getOridnal', function(){ expect(d.format('%o')).toEqual(d.get('ordinal')); From d2fc7a420e30d971aefa7b3da5117f0ea701214c Mon Sep 17 00:00:00 2001 From: Henning Bopp Date: Sun, 5 Feb 2017 16:54:09 +0100 Subject: [PATCH 4/4] Make the test to test something... --- Specs/Types/Date.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Specs/Types/Date.js b/Specs/Types/Date.js index 6e7ede61..42d6976f 100644 --- a/Specs/Types/Date.js +++ b/Specs/Types/Date.js @@ -425,6 +425,8 @@ describe('Date', function(){ expect(d.format('%M')).toEqual('02'); }); it('should return the month as one digit', function(){ + var d2 = new Date('Sun Feb 5 2017 13:37:42'); + expect(d2.format('%n')).toEqual('2'); expect(d.format('%n')).toEqual('11'); }); it('should return the ordinal, and should be the same as .getOridnal', function(){