Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit 00b0f41

Browse files
authored
Merge pull request #80 from TimeChimp/feat/updates
minor bug fixes
2 parents 3453ea0 + 810e773 commit 00b0f41

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "git",
55
"url": "https://github.com/timechimp/timechimp-typescript-helpers.git"
66
},
7-
"version": "1.0.2",
7+
"version": "1.0.3",
88
"license": "MIT",
99
"author": "TimeChimp",
1010
"main": "dist/index.js",

src/common/utils/__tests__/date.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('utils/date', () => {
1919
it('should format a utc date to a local timezone', () => {
2020
const date = new Date(Date.UTC(2020, 1, 1, 1, 1, 0, 0));
2121
const timezoneOffsetInHours =
22-
new Date().getTimezoneOffset() / MINUTES_IN_HOUR;
22+
new Date(2020, 0, 1).getTimezoneOffset() / MINUTES_IN_HOUR;
2323
const timeInHours = 1 - timezoneOffsetInHours;
2424

2525
expect(new TcDate(date).format('H:mm', 'nl-NL')).toBe(
@@ -30,7 +30,7 @@ describe('utils/date', () => {
3030
it('should treat input without timezone as UTC', () => {
3131
const date = '2021-03-24T06:00:00';
3232
const timezoneOffsetInHours =
33-
new Date().getTimezoneOffset() / MINUTES_IN_HOUR;
33+
new Date(2021, 2, 24).getTimezoneOffset() / MINUTES_IN_HOUR;
3434
const timeInHours = 6 - timezoneOffsetInHours;
3535

3636
expect(new TcDate(date).format('H:mm', 'nl-NL')).toBe(

src/common/utils/__tests__/time-parser.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ describe('TimeEntryDurationField', () => {
3737
{ input: '12', expectedResult: '12:00' },
3838
{ input: '123', expectedResult: '01:23' },
3939
{ input: '1234', expectedResult: '12:34' },
40+
{ input: '2:00', expectedResult: '02:00' },
4041
{ input: '03', expectedResult: '00:03' },
4142
{ input: '003', expectedResult: '00:03' },
4243
{ input: '022', expectedResult: '00:22' },

src/common/utils/time-parser.ts

+7
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ export class TimeParser {
201201
fromHoursAndMinutesSigned
202202
),
203203

204+
// 2 digits with separator
205+
new TimeParseRule(
206+
/^(?<hours>\d{1,2}):(?<minutes>\d{2})$/giu,
207+
value,
208+
fromHoursAndMinutesSigned
209+
),
210+
204211
// Scenario for single digits with separator
205212
new TimeParseRule(
206213
/^(?<sign>-)?(?<hours>\d[,.;]\d)$/giu,

0 commit comments

Comments
 (0)