@etsoo/shared 1.1.53 → 1.1.54

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.
@@ -56,15 +56,15 @@ test('Tests for formatForInput', () => {
56
56
  const result1 = DateUtils.formatForInput('2021/7/17');
57
57
  expect(result1).toBe('2021-07-17');
58
58
 
59
- const d = new Date(2021, 5, 6, 20, 18, 45);
59
+ const d = new Date(2021, 5, 6, 20, 8, 45);
60
60
  const result2 = DateUtils.formatForInput(d);
61
61
  expect(result2).toBe('2021-06-06');
62
62
 
63
63
  const result3 = DateUtils.formatForInput(d, false);
64
- expect(result3).toBe('2021-06-06T20:18');
64
+ expect(result3).toBe('2021-06-06T20:08');
65
65
 
66
66
  const result4 = DateUtils.formatForInput(d, true);
67
- expect(result4).toBe('2021-06-06T20:18:45');
67
+ expect(result4).toBe('2021-06-06T20:08:45');
68
68
  });
69
69
 
70
70
  test('Tests for substract', () => {
@@ -112,9 +112,12 @@ var DateUtils;
112
112
  const d = parts.join('-');
113
113
  if (hasSecond == null)
114
114
  return d;
115
- const hm = [date.getHours(), date.getMinutes()];
115
+ const hm = [
116
+ date.getHours().toString().padStart(2, '0'),
117
+ date.getMinutes().toString().padStart(2, '0')
118
+ ];
116
119
  if (hasSecond)
117
- hm.push(date.getSeconds());
120
+ hm.push(date.getSeconds().toString().padStart(2, '0'));
118
121
  return `${d}T${hm.join(':')}`;
119
122
  }
120
123
  DateUtils.formatForInput = formatForInput;
@@ -109,9 +109,12 @@ export var DateUtils;
109
109
  const d = parts.join('-');
110
110
  if (hasSecond == null)
111
111
  return d;
112
- const hm = [date.getHours(), date.getMinutes()];
112
+ const hm = [
113
+ date.getHours().toString().padStart(2, '0'),
114
+ date.getMinutes().toString().padStart(2, '0')
115
+ ];
113
116
  if (hasSecond)
114
- hm.push(date.getSeconds());
117
+ hm.push(date.getSeconds().toString().padStart(2, '0'));
115
118
  return `${d}T${hm.join(':')}`;
116
119
  }
117
120
  DateUtils.formatForInput = formatForInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/shared",
3
- "version": "1.1.53",
3
+ "version": "1.1.54",
4
4
  "description": "TypeScript shared utilities and functions",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
package/src/DateUtils.ts CHANGED
@@ -170,8 +170,11 @@ export namespace DateUtils {
170
170
  const d = parts.join('-');
171
171
  if (hasSecond == null) return d;
172
172
 
173
- const hm = [date.getHours(), date.getMinutes()];
174
- if (hasSecond) hm.push(date.getSeconds());
173
+ const hm = [
174
+ date.getHours().toString().padStart(2, '0'),
175
+ date.getMinutes().toString().padStart(2, '0')
176
+ ];
177
+ if (hasSecond) hm.push(date.getSeconds().toString().padStart(2, '0'));
175
178
  return `${d}T${hm.join(':')}`;
176
179
  }
177
180