date-format 4.0.8 → 4.0.11

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,64 +1,92 @@
1
1
  # date-format Changelog
2
2
 
3
+ ## 4.0.11
4
+
5
+ - [fix: date parsing errors (wrong month due to days overflow)](https://github.com/nomiddlename/date-format/pull/68) - thanks [@peteriman](https://github.com/peteriman)
6
+ - [test: use new Date(0) instead of new Date() before setting every field]() - thanks [@peteriman](https://github.com/peteriman)
7
+ - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/70) - thanks [@peteriman](https://github.com/peteriman)
8
+ - chore(deps-dev): bump eslint from 8.15.0 to 8.16.0
9
+ - chore(deps-dev): bump eslint-plugin-mocha from 10.0.4 to 10.0.5
10
+ - chore(deps-dev): updated package-lock.json
11
+
12
+ ## 4.0.10
13
+
14
+ - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/66) - thanks [@peteriman](https://github.com/peteriman)
15
+ - chore(deps-dev): bump eslint from 8.14.0 to 8.15.0
16
+ - chore(deps-dev): bump mocha from 9.2.2 to 10.0.0
17
+ - chore(deps-dev): updated package-lock.json
18
+
19
+ ## 4.0.9
20
+
21
+ - build: is exactly the same as 4.0.8 and is a re-published 4.0.8 to npm
22
+
23
+ ## 4.0.8
24
+
25
+ - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/60) - thanks [@peteriman](https://github.com/peteriman)
26
+ - chore(deps-dev): bump eslint from 8.13.0 to 8.14.0
27
+ - chore(deps-dev): updated package-lock.json
28
+ - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/59) - thanks [@peteriman](https://github.com/peteriman)
29
+ - chore(deps-dev): updated package-lock.json
30
+
3
31
  ## 4.0.7
4
32
 
5
- - [chore(dep): updated dependencies](https://github.com/nomiddlename/date-format/pull/57) - thanks [@peteriman](https://github.com/peteriman)
6
- - chore(dev): bump eslint-plugin-mocha from 10.0.3 to 10.0.4
7
- - updated package-lock.json
8
- - [chore(dep): updated dependencies](https://github.com/nomiddlename/date-format/pull/54) - thanks [@peteriman](https://github.com/peteriman)
9
- - chore(dev): bump eslint from 8.11.0 to 8.13.0
10
- - package-lock.json
33
+ - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/57) - thanks [@peteriman](https://github.com/peteriman)
34
+ - chore(deps-dev): bump eslint-plugin-mocha from 10.0.3 to 10.0.4
35
+ - chore(deps-dev): updated package-lock.json
36
+ - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/54) - thanks [@peteriman](https://github.com/peteriman)
37
+ - chore(deps-dev): bump eslint from 8.11.0 to 8.13.0
38
+ - chore(deps-dev): updated package-lock.json
11
39
 
12
40
  ## 4.0.6
13
41
 
14
- - [chore(dep): updated dependencies](https://github.com/nomiddlename/date-format/pull/52) - thanks [@peteriman](https://github.com/peteriman)
15
- - package-lock.json
42
+ - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/52) - thanks [@peteriman](https://github.com/peteriman)
43
+ - chore(deps-dev): updated package-lock.json
16
44
 
17
45
  ## 4.0.5
18
46
 
19
- - [chore(test): better test coverage instead of ignoring](https://github.com/nomiddlename/date-format/pull/48) - thanks [@peteriman](https://github.com/peteriman)
20
- - [chore(dep): updated dependencies](https://github.com/nomiddlename/date-format/pull/49) - thanks [@peteriman](https://github.com/peteriman)
21
- - chore(dev): eslint from 8.10.0 to 8.11.0
22
- - chore(dev): mocha from 9.2.1 to 9.2.2
23
- - package-lock.json
24
- - [chore(docs): updated README.md with badges](https://github.com/nomiddlename/date-format/pull/50) thanks [@peteriman](https://github.com/peteriman)
47
+ - [test: better test coverage instead of ignoring](https://github.com/nomiddlename/date-format/pull/48) - thanks [@peteriman](https://github.com/peteriman)
48
+ - [docs: updated README.md with badges](https://github.com/nomiddlename/date-format/pull/50) thanks [@peteriman](https://github.com/peteriman)
49
+ - [chore(deps-dev): updated dependencies](https://github.com/nomiddlename/date-format/pull/49) - thanks [@peteriman](https://github.com/peteriman)
50
+ - chore(deps-dev): bump eslint from 8.10.0 to 8.11.0
51
+ - chore(deps-dev): bump mocha from 9.2.1 to 9.2.2
52
+ - chore(deps-dev): updated package-lock.json
25
53
 
26
54
  ## 4.0.4
27
55
 
28
- - Updated dependencies - thanks [@peteriman](https://github.com/peteriman)
29
- - [chore(dev): 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)
30
- - [chore(dev): 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)
31
- - [package-lock.json](https://github.com/nomiddlename/date-format/pull/44)
56
+ - chore(deps-dev): updated dependencies - thanks [@peteriman](https://github.com/peteriman)
57
+ - [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)
58
+ - [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)
59
+ - [chore(deps-dev): updated package-lock.json](https://github.com/nomiddlename/date-format/pull/44)
32
60
 
33
61
  ## 4.0.3
34
62
 
35
- - [100% test coverage](https://github.com/nomiddlename/date-format/pull/42) - thanks [@peteriman](https://github.com/peteriman)
36
- - Updated dependencies - thanks [@peteriman](https://github.com/peteriman)
37
- - [chore(dev): 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)
63
+ - [test: 100% test coverage](https://github.com/nomiddlename/date-format/pull/42) - thanks [@peteriman](https://github.com/peteriman)
64
+ - chore(deps-dev): updated dependencies - thanks [@peteriman](https://github.com/peteriman)
65
+ - [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)
38
66
 
39
67
  ## 4.0.2
40
68
 
41
- - [Not to publish misc files to NPM](https://github.com/nomiddlename/date-format/pull/39) - thanks [@peteriman](https://github.com/peteriman)
42
- - CHANGELOG.md
43
- - [Removed "log4js" from title of CHANGELOG.md](https://github.com/nomiddlename/date-format/pull/37) - thanks [@joshuabremerdexcom](https://github.com/joshuabremerdexcom)
44
- - [Added "date-format" to title of CHANGELOG.md](https://github.com/nomiddlename/date-format/commit/64a95d0386853692d7d65174f94a0751e775f7ce#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed) - thanks [@peteriman](https://github.com/peteriman)
45
- - Updated dependencies - thanks [@peteriman](https://github.com/peteriman)
46
- - [chore(dev): eslint-plugin-mocha from 5.3.0 to 10.0.3](https://github.com/nomiddlename/date-format/pull/38)
69
+ - [build: not to publish misc files to NPM](https://github.com/nomiddlename/date-format/pull/39) - thanks [@peteriman](https://github.com/peteriman)
70
+ - docs: CHANGELOG.md
71
+ - [docs: removed "log4js" from title of CHANGELOG.md](https://github.com/nomiddlename/date-format/pull/37) - thanks [@joshuabremerdexcom](https://github.com/joshuabremerdexcom)
72
+ - [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)
73
+ - chore(deps-dev): updated dependencies - thanks [@peteriman](https://github.com/peteriman)
74
+ - [chore(deps-dev): bump eslint-plugin-mocha from 5.3.0 to 10.0.3](https://github.com/nomiddlename/date-format/pull/38)
47
75
 
48
76
  ## 4.0.1
49
77
 
50
- - is exactly the same as 4.0.0 and is a re-published 4.0.0 to npm
78
+ - build: is exactly the same as 4.0.0 and is a re-published 4.0.0 to npm
51
79
 
52
80
  ## 4.0.0
53
81
 
54
- - [Fix timezone format to include colon separator](https://github.com/nomiddlename/date-format/pull/27) - thanks [@peteriman](https://github.com/peteriman)
82
+ - [fix: timezone format to include colon separator](https://github.com/nomiddlename/date-format/pull/27) - thanks [@peteriman](https://github.com/peteriman)
55
83
  - [test: have a test case for timezone with colon](https://github.com/nomiddlename/date-format/pull/32) - thanks [@peteriman](https://github.com/peteriman)
56
- - [Docs: Updated README.md with more examples and expected output](https://github.com/nomiddlename/date-format/pull/33) - thanks [@peteriman](https://github.com/peteriman)
57
- - Updated dependencies
58
- - [should-util from 1.0.0 to 1.0.1](https://github.com/nomiddlename/date-format/pull/31) - thanks [@peteriman](https://github.com/peteriman)
59
- - [chore(dev): 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)
60
- - [acorn from 6.2.0 to 6.4.2](https://github.com/nomiddlename/date-format/pull/29) - thanks [@Dependabot](https://github.com/dependabot)
61
- - [lodash from 4.17.14 to 4.17.21](https://github.com/nomiddlename/date-format/pull/26) - thanks [@Dependabot](https://github.com/dependabot)
84
+ - [docs: updated README.md with more examples and expected output](https://github.com/nomiddlename/date-format/pull/33) - thanks [@peteriman](https://github.com/peteriman)
85
+ - chore(deps-dev): updated dependencies
86
+ - [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)
87
+ - [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)
88
+ - [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)
89
+ - [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)
62
90
 
63
91
  ## Previous versions
64
92
 
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.8",
3
+ "version": "4.0.11",
4
4
  "description": "Formatting Date objects as strings since 2013",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -29,9 +29,9 @@
29
29
  "readmeFilename": "README.md",
30
30
  "gitHead": "bf59015ab6c9e86454b179374f29debbdb403522",
31
31
  "devDependencies": {
32
- "eslint": "^8.14.0",
33
- "eslint-plugin-mocha": "^10.0.4",
34
- "mocha": "^9.2.2",
32
+ "eslint": "^8.16.0",
33
+ "eslint-plugin-mocha": "^10.0.5",
34
+ "mocha": "^10.0.0",
35
35
  "nyc": "^15.1.0",
36
36
  "should": "^13.2.3"
37
37
  },