date-format 4.0.10 → 4.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,8 +1,29 @@
1
1
  # date-format Changelog
2
2
 
3
+ ## 4.0.13
4
+
5
+ - [ci: added tests for Node.js 4.x, 6.x, 8.x, 10.x, 18.x](https://github.com/nomiddlename/date-format/pull/75) - thanks [@lamweili](https://github.com/lamweili)
6
+ - [chore(deps-dev): bump hosted-git-info from 2.6.0 to 2.8.9](https://github.com/nomiddlename/date-format/pull/76) - thanks [@Dependabot](https://github.com/dependabot)
7
+ - [chore(deps-dev): bump handlebars from 4.0.11 to 4.7.7 ](https://github.com/nomiddlename/date-format/pull/77) - thanks [@Dependabot](https://github.com/dependabot)
8
+ - [chore(deps-dev): bump y18n from 3.2.1 to 3.2.2](https://github.com/nomiddlename/date-format/pull/78) - thanks [@Dependabot](https://github.com/dependabot)
9
+
10
+ ## 4.0.12
11
+
12
+ - [ci: added tests for Node.js 8.x, 10.x, 18.x](https://github.com/nomiddlename/date-format/pull/73) - thanks [@lamweili](https://github.com/lamweili)
13
+ - [docs: renamed peteriman to lamweili](https://github.com/nomiddlename/date-format/pull/72) - thanks [@lamweili](https://github.com/lamweili)
14
+
15
+ ## 4.0.11
16
+
17
+ - [fix: date parsing errors (wrong month due to days overflow)](https://github.com/nomiddlename/date-format/pull/68) - thanks [@lamweili](https://github.com/lamweili)
18
+ - [test: use new Date(0) instead of new Date() before setting every field]() - thanks [@lamweili](https://github.com/lamweili)
19
+ - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/70) - thanks [@lamweili](https://github.com/lamweili)
20
+ - chore(deps-dev): bump eslint from 8.15.0 to 8.16.0
21
+ - chore(deps-dev): bump eslint-plugin-mocha from 10.0.4 to 10.0.5
22
+ - chore(deps-dev): updated package-lock.json
23
+
3
24
  ## 4.0.10
4
25
 
5
- - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/66) - thanks [@peteriman](https://github.com/peteriman)
26
+ - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/66) - thanks [@lamweili](https://github.com/lamweili)
6
27
  - chore(deps-dev): bump eslint from 8.14.0 to 8.15.0
7
28
  - chore(deps-dev): bump mocha from 9.2.2 to 10.0.0
8
29
  - chore(deps-dev): updated package-lock.json
@@ -13,55 +34,55 @@
13
34
 
14
35
  ## 4.0.8
15
36
 
16
- - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/60) - thanks [@peteriman](https://github.com/peteriman)
37
+ - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/60) - thanks [@lamweili](https://github.com/lamweili)
17
38
  - chore(deps-dev): bump eslint from 8.13.0 to 8.14.0
18
39
  - chore(deps-dev): updated package-lock.json
19
- - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/59) - thanks [@peteriman](https://github.com/peteriman)
40
+ - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/59) - thanks [@lamweili](https://github.com/lamweili)
20
41
  - chore(deps-dev): updated package-lock.json
21
42
 
22
43
  ## 4.0.7
23
44
 
24
- - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/57) - thanks [@peteriman](https://github.com/peteriman)
45
+ - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/57) - thanks [@lamweili](https://github.com/lamweili)
25
46
  - chore(deps-dev): bump eslint-plugin-mocha from 10.0.3 to 10.0.4
26
47
  - chore(deps-dev): updated package-lock.json
27
- - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/54) - thanks [@peteriman](https://github.com/peteriman)
48
+ - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/54) - thanks [@lamweili](https://github.com/lamweili)
28
49
  - chore(deps-dev): bump eslint from 8.11.0 to 8.13.0
29
50
  - chore(deps-dev): updated package-lock.json
30
51
 
31
52
  ## 4.0.6
32
53
 
33
- - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/52) - thanks [@peteriman](https://github.com/peteriman)
54
+ - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/52) - thanks [@lamweili](https://github.com/lamweili)
34
55
  - chore(deps-dev): updated package-lock.json
35
56
 
36
57
  ## 4.0.5
37
58
 
38
- - [test: better test coverage instead of ignoring](https://github.com/nomiddlename/date-format/pull/48) - thanks [@peteriman](https://github.com/peteriman)
39
- - [docs: updated README.md with badges](https://github.com/nomiddlename/date-format/pull/50) thanks [@peteriman](https://github.com/peteriman)
40
- - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/49) - thanks [@peteriman](https://github.com/peteriman)
59
+ - [test: better test coverage instead of ignoring](https://github.com/nomiddlename/date-format/pull/48) - thanks [@lamweili](https://github.com/lamweili)
60
+ - [docs: updated README.md with badges](https://github.com/nomiddlename/date-format/pull/50) thanks [@lamweili](https://github.com/lamweili)
61
+ - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/49) - thanks [@lamweili](https://github.com/lamweili)
41
62
  - chore(deps-dev): bump eslint from 8.10.0 to 8.11.0
42
63
  - chore(deps-dev): bump mocha from 9.2.1 to 9.2.2
43
64
  - chore(deps-dev): updated package-lock.json
44
65
 
45
66
  ## 4.0.4
46
67
 
47
- - chore(deps-dev): updated dependencies - thanks [@peteriman](https://github.com/peteriman)
68
+ - chore(deps-dev): updated dependencies - thanks [@lamweili](https://github.com/lamweili)
48
69
  - [chore(deps-dev): bump eslint from 8.8.0 to 8.10.0 and mocha from 9.2.0 to 9.2.1](https://github.com/nomiddlename/date-format/pull/46)
49
70
  - [chore(deps-dev): bump eslint from 8.7.0 to 8.8.0 and mocha from 9.1.4 to 9.2.0](https://github.com/nomiddlename/date-format/pull/45)
50
71
  - [chore(deps-dev): updated package-lock.json](https://github.com/nomiddlename/date-format/pull/44)
51
72
 
52
73
  ## 4.0.3
53
74
 
54
- - [test: 100% test coverage](https://github.com/nomiddlename/date-format/pull/42) - thanks [@peteriman](https://github.com/peteriman)
55
- - chore(deps-dev): updated dependencies - thanks [@peteriman](https://github.com/peteriman)
75
+ - [test: 100% test coverage](https://github.com/nomiddlename/date-format/pull/42) - thanks [@lamweili](https://github.com/lamweili)
76
+ - chore(deps-dev): updated dependencies - thanks [@lamweili](https://github.com/lamweili)
56
77
  - [chore(deps-dev): bump eslint from 8.6.0 to 8.7.0 and mocha from 9.1.3 to 9.1.4](https://github.com/nomiddlename/date-format/pull/41)
57
78
 
58
79
  ## 4.0.2
59
80
 
60
- - [build: not to publish misc files to NPM](https://github.com/nomiddlename/date-format/pull/39) - thanks [@peteriman](https://github.com/peteriman)
81
+ - [build: not to publish misc files to NPM](https://github.com/nomiddlename/date-format/pull/39) - thanks [@lamweili](https://github.com/lamweili)
61
82
  - docs: CHANGELOG.md
62
83
  - [docs: removed "log4js" from title of CHANGELOG.md](https://github.com/nomiddlename/date-format/pull/37) - thanks [@joshuabremerdexcom](https://github.com/joshuabremerdexcom)
63
- - [docs: added "date-format" to title of CHANGELOG.md](https://github.com/nomiddlename/date-format/commit/64a95d0386853692d7d65174f94a0751e775f7ce#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed) - thanks [@peteriman](https://github.com/peteriman)
64
- - chore(deps-dev): updated dependencies - thanks [@peteriman](https://github.com/peteriman)
84
+ - [docs: added "date-format" to title of CHANGELOG.md](https://github.com/nomiddlename/date-format/commit/64a95d0386853692d7d65174f94a0751e775f7ce#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed) - thanks [@lamweili](https://github.com/lamweili)
85
+ - chore(deps-dev): updated dependencies - thanks [@lamweili](https://github.com/lamweili)
65
86
  - [chore(deps-dev): bump eslint-plugin-mocha from 5.3.0 to 10.0.3](https://github.com/nomiddlename/date-format/pull/38)
66
87
 
67
88
  ## 4.0.1
@@ -70,12 +91,12 @@
70
91
 
71
92
  ## 4.0.0
72
93
 
73
- - [fix: timezone format to include colon separator](https://github.com/nomiddlename/date-format/pull/27) - thanks [@peteriman](https://github.com/peteriman)
74
- - [test: have a test case for timezone with colon](https://github.com/nomiddlename/date-format/pull/32) - thanks [@peteriman](https://github.com/peteriman)
75
- - [docs: updated README.md with more examples and expected output](https://github.com/nomiddlename/date-format/pull/33) - thanks [@peteriman](https://github.com/peteriman)
94
+ - [fix: timezone format to include colon separator](https://github.com/nomiddlename/date-format/pull/27) - thanks [@lamweili](https://github.com/lamweili)
95
+ - [test: have a test case for timezone with colon](https://github.com/nomiddlename/date-format/pull/32) - thanks [@lamweili](https://github.com/lamweili)
96
+ - [docs: updated README.md with more examples and expected output](https://github.com/nomiddlename/date-format/pull/33) - thanks [@lamweili](https://github.com/lamweili)
76
97
  - chore(deps-dev): updated dependencies
77
- - [chore(deps-dev): bump should-util from 1.0.0 to 1.0.1](https://github.com/nomiddlename/date-format/pull/31) - thanks [@peteriman](https://github.com/peteriman)
78
- - [chore(deps-dev): bump eslint from 5.16.0 to 8.6.0 and mocha from 5.2.0 to 9.1.3](https://github.com/nomiddlename/date-format/pull/30) - thanks [@peteriman](https://github.com/peteriman)
98
+ - [chore(deps-dev): bump should-util from 1.0.0 to 1.0.1](https://github.com/nomiddlename/date-format/pull/31) - thanks [@lamweili](https://github.com/lamweili)
99
+ - [chore(deps-dev): bump eslint from 5.16.0 to 8.6.0 and mocha from 5.2.0 to 9.1.3](https://github.com/nomiddlename/date-format/pull/30) - thanks [@lamweili](https://github.com/lamweili)
79
100
  - [chore(deps-dev): bump acorn from 6.2.0 to 6.4.2](https://github.com/nomiddlename/date-format/pull/29) - thanks [@Dependabot](https://github.com/dependabot)
80
101
  - [chore(deps-dev): bump lodash from 4.17.14 to 4.17.21](https://github.com/nomiddlename/date-format/pull/26) - thanks [@Dependabot](https://github.com/dependabot)
81
102
 
package/lib/index.js CHANGED
@@ -70,6 +70,7 @@ function extractDateParts(pattern, str, missingValuesDate) {
70
70
  // GMT based to begin with. If the timezone offset is provided, then adjust
71
71
  // it using provided timezone, otherwise, adjust it with the system timezone.
72
72
  var local = pattern.indexOf('O') < 0;
73
+ var monthOverflow = false;
73
74
  var matchers = [
74
75
  {
75
76
  pattern: /y{1,4}/,
@@ -83,12 +84,22 @@ function extractDateParts(pattern, str, missingValuesDate) {
83
84
  regexp: "\\d{1,2}",
84
85
  fn: function(date, value) {
85
86
  setDatePart(date, 'Month', (value - 1), local);
87
+ if (date.getMonth() !== (value - 1)) {
88
+ // in the event of 31 May --> 31 Feb --> 3 Mar
89
+ // this is correct behavior if no Date is involved
90
+ monthOverflow = true;
91
+ }
86
92
  }
87
93
  },
88
94
  {
89
95
  pattern: /dd/,
90
96
  regexp: "\\d{1,2}",
91
97
  fn: function(date, value) {
98
+ // in the event of 31 May --> 31 Feb --> 3 Mar
99
+ // reset Mar back to Feb, before setting the Date
100
+ if (monthOverflow) {
101
+ setDatePart(date, 'Month', (date.getMonth() - 1), local);
102
+ }
92
103
  setDatePart(date, 'Date', value, local);
93
104
  }
94
105
  },
@@ -149,7 +160,7 @@ function extractDateParts(pattern, str, missingValuesDate) {
149
160
  // representation was wrong. It needs to be fixed by substracting the
150
161
  // offset (or adding the offset minutes as they are opposite sign).
151
162
  //
152
- // Note: the time zone has to be processed after all other fileds are
163
+ // Note: the time zone has to be processed after all other fields are
153
164
  // set. The result would be incorrect if the offset was calculated
154
165
  // first then overriden by the other filed setters.
155
166
  date.setUTCMinutes(date.getUTCMinutes() + timezoneOffset);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "date-format",
3
- "version": "4.0.10",
3
+ "version": "4.0.13",
4
4
  "description": "Formatting Date objects as strings since 2013",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -29,10 +29,10 @@
29
29
  "readmeFilename": "README.md",
30
30
  "gitHead": "bf59015ab6c9e86454b179374f29debbdb403522",
31
31
  "devDependencies": {
32
- "eslint": "^8.15.0",
33
- "eslint-plugin-mocha": "^10.0.4",
34
- "mocha": "^10.0.0",
35
- "nyc": "^15.1.0",
32
+ "eslint": "^4.19.1",
33
+ "eslint-plugin-mocha": "^4.12.1",
34
+ "mocha": "^5.2.0",
35
+ "nyc": "13.0.0",
36
36
  "should": "^13.2.3"
37
37
  },
38
38
  "nyc": {