@cityssm/utils-datetime 1.1.0 → 1.1.1

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.
@@ -22,7 +22,7 @@ export function dateIntegerToDate(
22
22
  return undefined
23
23
  }
24
24
 
25
- const dateString = `00000000${(dateInteger as number).toString()}`.slice(-8)
25
+ const dateString = `00000000${dateInteger.toString()}`.slice(-8)
26
26
 
27
27
  const timeString = `0000${(timeInteger ?? 0).toString()}`.slice(-4)
28
28
 
@@ -18,5 +18,5 @@ export function dateIntegerToString(
18
18
  return ''
19
19
  }
20
20
 
21
- return dateToString(dateIntegerToDate(dateInteger as number))
21
+ return dateToString(dateIntegerToDate(dateInteger))
22
22
  }
@@ -1 +1 @@
1
- export declare function isValidDateInteger(possibleDateInteger: unknown): boolean;
1
+ export declare function isValidDateInteger(possibleDateInteger: unknown): possibleDateInteger is number;
@@ -3,7 +3,9 @@
3
3
  * @param {unknown} possibleDateInteger - A possible date number
4
4
  * @returns {boolean} - True if the possible date integer is valid.
5
5
  */
6
- export function isValidDateInteger(possibleDateInteger: unknown): boolean {
6
+ export function isValidDateInteger(
7
+ possibleDateInteger: unknown
8
+ ): possibleDateInteger is number {
7
9
  return (
8
10
  typeof possibleDateInteger === 'number' &&
9
11
  possibleDateInteger >= 101 &&
@@ -1 +1,2 @@
1
- export declare function isValidDateString(possibleDateString: unknown): boolean;
1
+ import type { DateString } from './dateTimeTypes.js';
2
+ export declare function isValidDateString(possibleDateString: unknown): possibleDateString is DateString;
@@ -1,3 +1,5 @@
1
+ import type { DateString } from './dateTimeTypes.js'
2
+
1
3
  const dateStringRegex = /^\d{4}-[01]\d-[0-3]\d$/
2
4
 
3
5
  /**
@@ -5,7 +7,9 @@ const dateStringRegex = /^\d{4}-[01]\d-[0-3]\d$/
5
7
  * @param {unknown} possibleDateString - A possible date string
6
8
  * @returns {boolean} - True when the possible date string is valid
7
9
  */
8
- export function isValidDateString(possibleDateString: unknown): boolean {
10
+ export function isValidDateString(
11
+ possibleDateString: unknown
12
+ ): possibleDateString is DateString {
9
13
  return (
10
14
  typeof possibleDateString === 'string' &&
11
15
  (possibleDateString ?? '').length === 10 &&
@@ -1 +1 @@
1
- export declare function isValidTimeInteger(possibleTimeInteger: unknown): boolean;
1
+ export declare function isValidTimeInteger(possibleTimeInteger: unknown): possibleTimeInteger is number;
@@ -3,7 +3,9 @@
3
3
  * @param {unknown} possibleTimeInteger - A possible time number
4
4
  * @returns {boolean} - True if the possible time integer is valid.
5
5
  */
6
- export function isValidTimeInteger(possibleTimeInteger: unknown): boolean {
6
+ export function isValidTimeInteger(
7
+ possibleTimeInteger: unknown
8
+ ): possibleTimeInteger is number {
7
9
  return (
8
10
  typeof possibleTimeInteger === 'number' &&
9
11
  possibleTimeInteger >= 0 &&
@@ -1 +1,2 @@
1
- export declare function isValidTimeString(possibleTimeString: unknown): boolean;
1
+ import type { TimeString } from './dateTimeTypes.js';
2
+ export declare function isValidTimeString(possibleTimeString: unknown): possibleTimeString is TimeString;
@@ -1,3 +1,5 @@
1
+ import type { TimeString } from './dateTimeTypes.js'
2
+
1
3
  const timeStringRegex = /^[01]\d:[0-5]\d$/
2
4
 
3
5
  /**
@@ -5,7 +7,9 @@ const timeStringRegex = /^[01]\d:[0-5]\d$/
5
7
  * @param {unknown} possibleTimeString - A possible time string.
6
8
  * @returns {boolean} - True when the possible time string is valid.
7
9
  */
8
- export function isValidTimeString(possibleTimeString: unknown): boolean {
10
+ export function isValidTimeString(
11
+ possibleTimeString: unknown
12
+ ): possibleTimeString is TimeString {
9
13
  return (
10
14
  typeof possibleTimeString === 'string' &&
11
15
  (possibleTimeString ?? '').length === 5 &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityssm/utils-datetime",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Date time utilities for Node.js applications",
5
5
  "keywords": [
6
6
  "date",