Skip to content
This repository was archived by the owner on Dec 23, 2025. It is now read-only.

Commit b4a0cf5

Browse files
committed
feat: ⌚ add duration object and duration parsing
1 parent 6aaee89 commit b4a0cf5

File tree

3 files changed

+62
-12
lines changed

3 files changed

+62
-12
lines changed

apps/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
"tildify": "^3.0.0",
143143
"tslib": "^2.6.2",
144144
"type-fest": "^4.9.0",
145-
"typia": "^5.3.10",
145+
"typia": "^5.4.1",
146146
"untildify": "^5.0.0"
147147
},
148148
"devDependencies": {
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import {tags} from 'typia'
2+
import type {Opaque} from '../../libraries/opaque.ts'
3+
4+
export namespace Duration {
5+
6+
export type Years = Opaque<number & tags.Type<'int32'>, 'year'>
7+
export type Months = Opaque<number & tags.Type<'int32'>, 'month'>
8+
export type Days = Opaque<number & tags.Type<'int32'>, 'day'>
9+
export type Hours = Opaque<number & tags.Type<'int32'>, 'hour'>
10+
export type Minutes = Opaque<number & tags.Type<'int32'>, 'minute'>
11+
export type Seconds = Opaque<number & tags.Type<'int32'>, 'second'>
12+
export type Milliseconds = Opaque<number & tags.Type<'int32'>, 'millisecond'>
13+
14+
15+
16+
export const Years = (value: unknown): value is Years => {
17+
}
18+
19+
}
20+
21+
22+
export type DurationString = Opaque<string & tags.Format<"duration">, 'duration'>
23+
24+
export interface DurationObject {
25+
readonly years?: Duration.Years
26+
readonly months?: Duration.Months
27+
readonly days?: Duration.Days
28+
readonly hours?: Duration.Hours
29+
readonly minutes?: Duration.Minutes
30+
readonly seconds?: Duration.Seconds
31+
readonly milliseconds?: Duration.Milliseconds
32+
}
33+
34+
export type DurationLike = DurationObject | number | string | Duration.Milliseconds | DurationString
35+
36+
class Duration implements DurationObject {
37+
38+
constructor(duration: DurationLike)
39+
{
40+
}
41+
42+
static parse(duration: DurationLike): Duration
43+
{
44+
// TODO: Create implementation of parsing duration objects
45+
46+
47+
48+
return new Duration(duration)
49+
}
50+
}

pnpm-lock.yaml

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)