date-format 4.0.9 → 4.0.12

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