Skip to content

Commit f7d76eb

Browse files
palbizuPatricio Albizu
andauthored
feat: toISOString Time function (#1351)
* feat: toISOString Time function * feat: adding uts Co-authored-by: Patricio Albizu <patricioalbizu@Patricios-MacBook-Pro.local>
1 parent 180e753 commit f7d76eb

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

projects/common/src/time/time.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Time } from './time';
2+
3+
describe('Time', () => {
4+
const mockedTime = new Time(8, 30);
5+
6+
test('can get label', () => {
7+
expect(mockedTime.label).toBe('8:30 AM');
8+
});
9+
10+
test('can get date', () => {
11+
expect(mockedTime.date).toEqual(new Date(`${new Date().toDateString()} 08:30Z`));
12+
});
13+
14+
test('can get ISO String from time', () => {
15+
expect(mockedTime.toISOString()).toBe('08:30:00.000Z');
16+
});
17+
});

projects/common/src/time/time.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@ export class Time {
3131
public get date(): Date {
3232
return this._date;
3333
}
34+
35+
public toISOString(): string {
36+
return this.date.toISOString().substring(11);
37+
}
3438
}

0 commit comments

Comments
 (0)