@cityssm/utils-datetime 0.1.0

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.
Files changed (45) hide show
  1. package/CODE_OF_CONDUCT.md +140 -0
  2. package/CONTRIBUTING.md +33 -0
  3. package/LICENSE +21 -0
  4. package/README.md +5 -0
  5. package/SECURITY.md +15 -0
  6. package/dateIntegerToDate.d.ts +1 -0
  7. package/dateIntegerToDate.js +11 -0
  8. package/dateIntegerToDate.ts +25 -0
  9. package/dateIntegerToString.d.ts +1 -0
  10. package/dateIntegerToString.js +8 -0
  11. package/dateIntegerToString.ts +10 -0
  12. package/dateStringToDate.d.ts +1 -0
  13. package/dateStringToDate.js +5 -0
  14. package/dateStringToDate.ts +15 -0
  15. package/dateStringToInteger.d.ts +1 -0
  16. package/dateStringToInteger.js +5 -0
  17. package/dateStringToInteger.ts +6 -0
  18. package/dateToInteger.d.ts +1 -0
  19. package/dateToInteger.js +5 -0
  20. package/dateToInteger.ts +7 -0
  21. package/dateToString.d.ts +1 -0
  22. package/dateToString.js +7 -0
  23. package/dateToString.ts +7 -0
  24. package/dateToTimeInteger.d.ts +1 -0
  25. package/dateToTimeInteger.js +3 -0
  26. package/dateToTimeInteger.ts +3 -0
  27. package/dateToTimePeriodString.d.ts +1 -0
  28. package/dateToTimePeriodString.js +9 -0
  29. package/dateToTimePeriodString.ts +9 -0
  30. package/dateToTimeString.d.ts +1 -0
  31. package/dateToTimeString.js +7 -0
  32. package/dateToTimeString.ts +7 -0
  33. package/index.d.ts +14 -0
  34. package/index.js +35 -0
  35. package/index.ts +56 -0
  36. package/package.json +30 -0
  37. package/timeIntegerToPeriodString.d.ts +1 -0
  38. package/timeIntegerToPeriodString.js +5 -0
  39. package/timeIntegerToPeriodString.ts +6 -0
  40. package/timeIntegerToString.d.ts +1 -0
  41. package/timeIntegerToString.js +4 -0
  42. package/timeIntegerToString.ts +4 -0
  43. package/timeStringToInteger.d.ts +1 -0
  44. package/timeStringToInteger.js +3 -0
  45. package/timeStringToInteger.ts +3 -0
@@ -0,0 +1,140 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ - Demonstrating empathy and kindness toward other people
21
+
22
+ - Being respectful of differing opinions, viewpoints, and experiences
23
+
24
+ - Giving and gracefully accepting constructive feedback
25
+
26
+ - Accepting responsibility and apologizing to those affected by our mistakes,
27
+ and learning from the experience
28
+
29
+ - Focusing on what is best not just for us as individuals, but for the overall
30
+ community
31
+
32
+ Examples of unacceptable behavior include:
33
+
34
+ - The use of sexualized language or imagery, and sexual attention or advances of
35
+ any kind
36
+
37
+ - Trolling, insulting or derogatory comments, and personal or political attacks
38
+
39
+ - Public or private harassment
40
+
41
+ - Publishing others' private information, such as a physical or email address,
42
+ without their explicit permission
43
+
44
+ - Other conduct which could reasonably be considered inappropriate in a
45
+ professional setting
46
+
47
+ ## Enforcement Responsibilities
48
+
49
+ Community leaders are responsible for clarifying and enforcing our standards of
50
+ acceptable behavior and will take appropriate and fair corrective action in
51
+ response to any behavior that they deem inappropriate, threatening, offensive,
52
+ or harmful.
53
+
54
+ Community leaders have the right and responsibility to remove, edit, or reject
55
+ comments, commits, code, wiki edits, issues, and other contributions that are
56
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
57
+ decisions when appropriate.
58
+
59
+ ## Scope
60
+
61
+ This Code of Conduct applies within all community spaces, and also applies when
62
+ an individual is officially representing the community in public spaces.
63
+ Examples of representing our community include using an official e-mail address,
64
+ posting via an official social media account, or acting as an appointed
65
+ representative at an online or offline event.
66
+
67
+ ## Enforcement
68
+
69
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
70
+ reported to the community leaders responsible for enforcement at
71
+ **corporateapps@cityssm.on.ca**.
72
+ All complaints will be reviewed and investigated promptly and fairly.
73
+
74
+ All community leaders are obligated to respect the privacy and security of the
75
+ reporter of any incident.
76
+
77
+ ## Enforcement Guidelines
78
+
79
+ Community leaders will follow these Community Impact Guidelines in determining
80
+ the consequences for any action they deem in violation of this Code of Conduct:
81
+
82
+ ### 1. Correction
83
+
84
+ **Community Impact**: Use of inappropriate language or other behavior deemed
85
+ unprofessional or unwelcome in the community.
86
+
87
+ **Consequence**: A private, written warning from community leaders, providing
88
+ clarity around the nature of the violation and an explanation of why the
89
+ behavior was inappropriate. A public apology may be requested.
90
+
91
+ ### 2. Warning
92
+
93
+ **Community Impact**: A violation through a single incident or series of
94
+ actions.
95
+
96
+ **Consequence**: A warning with consequences for continued behavior. No
97
+ interaction with the people involved, including unsolicited interaction with
98
+ those enforcing the Code of Conduct, for a specified period of time. This
99
+ includes avoiding interactions in community spaces as well as external channels
100
+ like social media. Violating these terms may lead to a temporary or permanent
101
+ ban.
102
+
103
+ ### 3. Temporary Ban
104
+
105
+ **Community Impact**: A serious violation of community standards, including
106
+ sustained inappropriate behavior.
107
+
108
+ **Consequence**: A temporary ban from any sort of interaction or public
109
+ communication with the community for a specified period of time. No public or
110
+ private interaction with the people involved, including unsolicited interaction
111
+ with those enforcing the Code of Conduct, is allowed during this period.
112
+ Violating these terms may lead to a permanent ban.
113
+
114
+ ### 4. Permanent Ban
115
+
116
+ **Community Impact**: Demonstrating a pattern of violation of community
117
+ standards, including sustained inappropriate behavior, harassment of an
118
+ individual, or aggression toward or disparagement of classes of individuals.
119
+
120
+ **Consequence**: A permanent ban from any sort of public interaction within the
121
+ community.
122
+
123
+ ## Attribution
124
+
125
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
126
+ version 2.1, available at
127
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
128
+
129
+ Community Impact Guidelines were inspired by
130
+ [Mozilla's code of conduct enforcement ladder][mozilla coc].
131
+
132
+ For answers to common questions about this code of conduct, see the FAQ at
133
+ [https://www.contributor-covenant.org/faq][faq]. Translations are available at
134
+ [https://www.contributor-covenant.org/translations][translations].
135
+
136
+ [homepage]: https://www.contributor-covenant.org
137
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
138
+ [mozilla coc]: https://github.com/mozilla/diversity
139
+ [faq]: https://www.contributor-covenant.org/faq
140
+ [translations]: https://www.contributor-covenant.org/translations
@@ -0,0 +1,33 @@
1
+ # Thank you for your interest in making the Date Time Utils package better
2
+
3
+ Together, we can build high quality software that meets the needs of municipalities,
4
+ while remaining open and budget conscious.
5
+
6
+ **Thank you for taking the time to read the contributing guidelines.**
7
+
8
+ ## All contributions are welcome
9
+
10
+ Being a very small team, contributions are greatly appreciated. How can you contribute?
11
+
12
+ - **Promote this project!**
13
+ - Documentation and tutorials
14
+ - Submit bug reports (or fix them!)
15
+ - Request new features (or build them!)
16
+
17
+ ## Please Read the Code of Conduct
18
+
19
+ The [Code of Conduct](CODE_OF_CONDUCT.md) document describes how we should act when working together.
20
+ Be nice! :smile:
21
+
22
+ ## How to report a bug or suggest an enhancement
23
+
24
+ **If you find a security vulnerability, do NOT open an issue. Email
25
+ <corporateapps@cityssm.on.ca> instead.**
26
+
27
+ For all other bug reports, feature requests, or enhancements,
28
+ open an issue and use the closest template.
29
+
30
+ ## Thanks Again
31
+
32
+ We are a very small team with big aspirations and limited resources.
33
+ Thank you for helping with this project in any way you can!
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 The City of Sault Ste. Marie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # node-utils-datetime
2
+
3
+ Date time utilities for Node.js applications.
4
+
5
+ Extracted from [expressjs-server-js](https://github.com/cityssm/expressjs-server-js).
package/SECURITY.md ADDED
@@ -0,0 +1,15 @@
1
+ # Security Policy
2
+
3
+ **Thank you for your interest in keeping this project safe for everyone.**
4
+
5
+ ## Supported Versions
6
+
7
+ Due to limited resources, only the latest version is supported only for security updates.
8
+
9
+ ## Reporting a Vulnerability
10
+
11
+ To report a security vulnerability,
12
+ please email <corporateapps@cityssm.on.ca>.
13
+
14
+ Every attempt will be made to resolve confirmed vulnerabilities
15
+ in a timely manner.
@@ -0,0 +1 @@
1
+ export declare function dateIntegerToDate(dateInteger: number | undefined | null, timeInteger?: number): Date | undefined;
@@ -0,0 +1,11 @@
1
+ export function dateIntegerToDate(dateInteger, timeInteger = 0) {
2
+ if (dateInteger === null ||
3
+ dateInteger === undefined ||
4
+ Number.isNaN(dateInteger) ||
5
+ dateInteger === 0) {
6
+ return;
7
+ }
8
+ const dateString = ('00000000' + dateInteger.toString()).slice(-8);
9
+ const timeString = ('0000' + (timeInteger ?? 0).toString()).slice(-4);
10
+ return new Date(Number.parseInt(dateString.slice(0, 4), 10), Number.parseInt(dateString.slice(4, 6), 10) - 1, Number.parseInt(dateString.slice(6, 8), 10), Number.parseInt(timeString.slice(0, 2), 10), Number.parseInt(timeString.slice(2, 4), 10));
11
+ }
@@ -0,0 +1,25 @@
1
+ export function dateIntegerToDate(
2
+ dateInteger: number | undefined | null,
3
+ timeInteger = 0
4
+ ): Date | undefined {
5
+ if (
6
+ dateInteger === null ||
7
+ dateInteger === undefined ||
8
+ Number.isNaN(dateInteger) ||
9
+ dateInteger === 0
10
+ ) {
11
+ return
12
+ }
13
+
14
+ const dateString = ('00000000' + dateInteger!.toString()).slice(-8)
15
+
16
+ const timeString = ('0000' + (timeInteger ?? 0).toString()).slice(-4)
17
+
18
+ return new Date(
19
+ Number.parseInt(dateString.slice(0, 4), 10),
20
+ Number.parseInt(dateString.slice(4, 6), 10) - 1,
21
+ Number.parseInt(dateString.slice(6, 8), 10),
22
+ Number.parseInt(timeString.slice(0, 2), 10),
23
+ Number.parseInt(timeString.slice(2, 4), 10)
24
+ )
25
+ }
@@ -0,0 +1 @@
1
+ export declare function dateIntegerToString(dateInteger: number | undefined | null): string | undefined;
@@ -0,0 +1,8 @@
1
+ import { dateIntegerToDate } from './dateIntegerToDate.js';
2
+ import { dateToString } from './dateToString.js';
3
+ export function dateIntegerToString(dateInteger) {
4
+ if (dateInteger === null || dateInteger === undefined || Number.isNaN(dateInteger) || dateInteger === 0) {
5
+ return '';
6
+ }
7
+ return dateToString(dateIntegerToDate(dateInteger));
8
+ }
@@ -0,0 +1,10 @@
1
+ import { dateIntegerToDate } from './dateIntegerToDate.js'
2
+ import { dateToString } from './dateToString.js'
3
+
4
+ export function dateIntegerToString(dateInteger: number | undefined | null): string | undefined {
5
+ if (dateInteger === null || dateInteger === undefined || Number.isNaN(dateInteger) || dateInteger === 0) {
6
+ return ''
7
+ }
8
+
9
+ return dateToString(dateIntegerToDate(dateInteger!)!)
10
+ }
@@ -0,0 +1 @@
1
+ export declare function dateStringToDate(dateString: string, timeString?: string): Date;
@@ -0,0 +1,5 @@
1
+ export function dateStringToDate(dateString, timeString = '00:00') {
2
+ const datePieces = dateString.split('-');
3
+ const timePieces = timeString.split(':');
4
+ return new Date(Number.parseInt(datePieces[0], 10), Number.parseInt(datePieces[1], 10) - 1, Number.parseInt(datePieces[2], 10), Number.parseInt(timePieces[0], 10), Number.parseInt(timePieces[1], 10), 0, 0);
5
+ }
@@ -0,0 +1,15 @@
1
+ export function dateStringToDate(dateString: string,
2
+ timeString = '00:00'): Date {
3
+ const datePieces = dateString.split('-')
4
+ const timePieces = timeString.split(':')
5
+
6
+ return new Date(
7
+ Number.parseInt(datePieces[0], 10),
8
+ Number.parseInt(datePieces[1], 10) - 1,
9
+ Number.parseInt(datePieces[2], 10),
10
+ Number.parseInt(timePieces[0], 10),
11
+ Number.parseInt(timePieces[1], 10),
12
+ 0,
13
+ 0
14
+ )
15
+ }
@@ -0,0 +1 @@
1
+ export declare function dateStringToInteger(dateString: string): number;
@@ -0,0 +1,5 @@
1
+ import { dateStringToDate } from './dateStringToDate.js';
2
+ import { dateToInteger } from './dateToInteger.js';
3
+ export function dateStringToInteger(dateString) {
4
+ return dateToInteger(dateStringToDate(dateString));
5
+ }
@@ -0,0 +1,6 @@
1
+ import { dateStringToDate } from './dateStringToDate.js'
2
+ import { dateToInteger } from './dateToInteger.js'
3
+
4
+ export function dateStringToInteger(dateString: string): number {
5
+ return dateToInteger(dateStringToDate(dateString))
6
+ }
@@ -0,0 +1 @@
1
+ export declare function dateToInteger(dateObject: Date): number;
@@ -0,0 +1,5 @@
1
+ export function dateToInteger(dateObject) {
2
+ return (dateObject.getFullYear() * 10000 +
3
+ (dateObject.getMonth() + 1) * 100 +
4
+ dateObject.getDate());
5
+ }
@@ -0,0 +1,7 @@
1
+ export function dateToInteger(dateObject: Date): number {
2
+ return (
3
+ dateObject.getFullYear() * 10000 +
4
+ (dateObject.getMonth() + 1) * 100 +
5
+ dateObject.getDate()
6
+ )
7
+ }
@@ -0,0 +1 @@
1
+ export declare function dateToString(dateObject: Date): string;
@@ -0,0 +1,7 @@
1
+ export function dateToString(dateObject) {
2
+ return Intl.DateTimeFormat('fr-CA', {
3
+ year: 'numeric',
4
+ month: '2-digit',
5
+ day: '2-digit'
6
+ }).format(dateObject);
7
+ }
@@ -0,0 +1,7 @@
1
+ export function dateToString(dateObject: Date): string {
2
+ return Intl.DateTimeFormat('fr-CA', {
3
+ year: 'numeric',
4
+ month: '2-digit',
5
+ day: '2-digit'
6
+ }).format(dateObject)
7
+ }
@@ -0,0 +1 @@
1
+ export declare function dateToTimeInteger(dateObject: Date): number;
@@ -0,0 +1,3 @@
1
+ export function dateToTimeInteger(dateObject) {
2
+ return dateObject.getHours() * 100 + dateObject.getMinutes();
3
+ }
@@ -0,0 +1,3 @@
1
+ export function dateToTimeInteger(dateObject: Date): number {
2
+ return dateObject.getHours() * 100 + dateObject.getMinutes()
3
+ }
@@ -0,0 +1 @@
1
+ export declare function dateToTimePeriodString(dateObject: Date): string;
@@ -0,0 +1,9 @@
1
+ export function dateToTimePeriodString(dateObject) {
2
+ return Intl.DateTimeFormat('en-CA', {
3
+ hourCycle: 'h12',
4
+ hour: 'numeric',
5
+ minute: '2-digit'
6
+ })
7
+ .format(dateObject)
8
+ .replace(/ /g, ' ');
9
+ }
@@ -0,0 +1,9 @@
1
+ export function dateToTimePeriodString(dateObject: Date): string {
2
+ return Intl.DateTimeFormat('en-CA', {
3
+ hourCycle: 'h12',
4
+ hour: 'numeric',
5
+ minute: '2-digit'
6
+ })
7
+ .format(dateObject)
8
+ .replace(/ /g, ' ')
9
+ }
@@ -0,0 +1 @@
1
+ export declare function dateToTimeString(dateObject: Date): string;
@@ -0,0 +1,7 @@
1
+ export function dateToTimeString(dateObject) {
2
+ return Intl.DateTimeFormat('en-CA', {
3
+ hourCycle: 'h24',
4
+ hour: '2-digit',
5
+ minute: '2-digit'
6
+ }).format(dateObject);
7
+ }
@@ -0,0 +1,7 @@
1
+ export function dateToTimeString(dateObject: Date): string {
2
+ return Intl.DateTimeFormat('en-CA', {
3
+ hourCycle: 'h24',
4
+ hour: '2-digit',
5
+ minute: '2-digit'
6
+ }).format(dateObject)
7
+ }
package/index.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ export declare const months: string[];
2
+ export declare const days: string[];
3
+ export { dateIntegerToDate } from './dateIntegerToDate.js';
4
+ export { dateStringToDate } from './dateStringToDate.js';
5
+ export { dateToInteger } from './dateToInteger.js';
6
+ export { dateToString } from './dateToString.js';
7
+ export { dateIntegerToString } from './dateIntegerToString.js';
8
+ export { dateStringToInteger } from './dateStringToInteger.js';
9
+ export { dateToTimeInteger } from './dateToTimeInteger.js';
10
+ export { dateToTimeString } from './dateToTimeString.js';
11
+ export { dateToTimePeriodString } from './dateToTimePeriodString.js';
12
+ export { timeIntegerToString } from './timeIntegerToString.js';
13
+ export { timeIntegerToPeriodString } from './timeIntegerToPeriodString.js';
14
+ export { timeStringToInteger } from './timeStringToInteger.js';
package/index.js ADDED
@@ -0,0 +1,35 @@
1
+ export const months = [
2
+ 'January',
3
+ 'February',
4
+ 'March',
5
+ 'April',
6
+ 'May',
7
+ 'June',
8
+ 'July',
9
+ 'August',
10
+ 'September',
11
+ 'October',
12
+ 'November',
13
+ 'December'
14
+ ];
15
+ export const days = [
16
+ 'Sunday',
17
+ 'Monday',
18
+ 'Tuesday',
19
+ 'Wednesday',
20
+ 'Thursday',
21
+ 'Friday',
22
+ 'Saturday'
23
+ ];
24
+ export { dateIntegerToDate } from './dateIntegerToDate.js';
25
+ export { dateStringToDate } from './dateStringToDate.js';
26
+ export { dateToInteger } from './dateToInteger.js';
27
+ export { dateToString } from './dateToString.js';
28
+ export { dateIntegerToString } from './dateIntegerToString.js';
29
+ export { dateStringToInteger } from './dateStringToInteger.js';
30
+ export { dateToTimeInteger } from './dateToTimeInteger.js';
31
+ export { dateToTimeString } from './dateToTimeString.js';
32
+ export { dateToTimePeriodString } from './dateToTimePeriodString.js';
33
+ export { timeIntegerToString } from './timeIntegerToString.js';
34
+ export { timeIntegerToPeriodString } from './timeIntegerToPeriodString.js';
35
+ export { timeStringToInteger } from './timeStringToInteger.js';
package/index.ts ADDED
@@ -0,0 +1,56 @@
1
+ export const months = [
2
+ 'January',
3
+ 'February',
4
+ 'March',
5
+ 'April',
6
+ 'May',
7
+ 'June',
8
+ 'July',
9
+ 'August',
10
+ 'September',
11
+ 'October',
12
+ 'November',
13
+ 'December'
14
+ ]
15
+
16
+ export const days = [
17
+ 'Sunday',
18
+ 'Monday',
19
+ 'Tuesday',
20
+ 'Wednesday',
21
+ 'Thursday',
22
+ 'Friday',
23
+ 'Saturday'
24
+ ]
25
+
26
+ /*
27
+ * Date Functions
28
+ */
29
+
30
+ // To Date Object
31
+ export { dateIntegerToDate } from './dateIntegerToDate.js'
32
+ export { dateStringToDate } from './dateStringToDate.js'
33
+
34
+ // From Date Object
35
+ export { dateToInteger } from './dateToInteger.js'
36
+ export { dateToString } from './dateToString.js'
37
+
38
+ // Helpers
39
+ export { dateIntegerToString } from './dateIntegerToString.js'
40
+ export { dateStringToInteger } from './dateStringToInteger.js'
41
+
42
+ /*
43
+ * Time Functions
44
+ */
45
+
46
+ // From Date Object
47
+ export { dateToTimeInteger } from './dateToTimeInteger.js'
48
+ export { dateToTimeString } from './dateToTimeString.js'
49
+ export { dateToTimePeriodString } from './dateToTimePeriodString.js'
50
+
51
+ // From Time Integer
52
+ export { timeIntegerToString } from './timeIntegerToString.js'
53
+ export { timeIntegerToPeriodString } from './timeIntegerToPeriodString.js'
54
+
55
+ // From Time String
56
+ export { timeStringToInteger } from './timeStringToInteger.js'
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@cityssm/utils-datetime",
3
+ "version": "0.1.0",
4
+ "description": "Date time utilities for Node.js applications",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
8
+ },
9
+ "exports": "./index.js",
10
+ "types": "./index.d.ts",
11
+ "directories": {
12
+ "test": "test"
13
+ },
14
+ "scripts": {
15
+ "test": "mocha",
16
+ "coverage": "c8 mocha"
17
+ },
18
+ "author": "The Corporation of the City of Sault Ste. Marie",
19
+ "license": "MIT",
20
+ "devDependencies": {
21
+ "@types/mocha": "^10.0.1",
22
+ "@types/node": "^18.15.5",
23
+ "@typescript-eslint/eslint-plugin": "^5.56.0",
24
+ "@typescript-eslint/parser": "^5.56.0",
25
+ "eslint": "^8.36.0",
26
+ "eslint-plugin-import": "^2.27.5",
27
+ "eslint-plugin-node": "^11.1.0",
28
+ "eslint-plugin-unicorn": "^46.0.0"
29
+ }
30
+ }
@@ -0,0 +1 @@
1
+ export declare function timeIntegerToPeriodString(timeInteger: number): string;
@@ -0,0 +1,5 @@
1
+ import { dateIntegerToDate } from './dateIntegerToDate.js';
2
+ import { dateToTimePeriodString } from './dateToTimePeriodString.js';
3
+ export function timeIntegerToPeriodString(timeInteger) {
4
+ return dateToTimePeriodString(dateIntegerToDate(19700101, timeInteger));
5
+ }
@@ -0,0 +1,6 @@
1
+ import { dateIntegerToDate } from './dateIntegerToDate.js'
2
+ import { dateToTimePeriodString } from './dateToTimePeriodString.js'
3
+
4
+ export function timeIntegerToPeriodString(timeInteger: number) {
5
+ return dateToTimePeriodString(dateIntegerToDate(19700101, timeInteger)!)
6
+ }
@@ -0,0 +1 @@
1
+ export declare function timeIntegerToString(timeInteger: number): string;
@@ -0,0 +1,4 @@
1
+ export function timeIntegerToString(timeInteger) {
2
+ const timeString = ('0000' + (timeInteger || 0).toString()).slice(-4);
3
+ return timeString.slice(0, 2) + ':' + timeString.slice(2, 4);
4
+ }
@@ -0,0 +1,4 @@
1
+ export function timeIntegerToString(timeInteger: number): string {
2
+ const timeString = ('0000' + (timeInteger || 0).toString()).slice(-4)
3
+ return timeString.slice(0, 2) + ':' + timeString.slice(2, 4)
4
+ }
@@ -0,0 +1 @@
1
+ export declare function timeStringToInteger(timeString: string): number;
@@ -0,0 +1,3 @@
1
+ export function timeStringToInteger(timeString) {
2
+ return Number.parseInt(('0' + timeString).replace(/:/g, ''), 10);
3
+ }
@@ -0,0 +1,3 @@
1
+ export function timeStringToInteger(timeString: string): number {
2
+ return Number.parseInt(('0' + timeString).replace(/:/g, ''), 10)
3
+ }