-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.ts
57 lines (31 loc) · 1.51 KB
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { TimeService } from './time-service.ts'
import * as log from "https://deno.land/std/log/mod.ts"
import { assertEquals } from "https://deno.land/std/testing/asserts.ts"
Deno.test("get time by offset", async (): Promise<void> => {
const offset = '+02:00'
const time = await TimeService.getTimeByOffset(offset)
log.info(`The time for offset ${offset} is ${time}`)
});
Deno.test("get timezone", async (): Promise<void> => {
const countryCode = 'DE'
const cityName = 'Heidelberg'
const timeZone = await TimeService.getTimeZone(countryCode, cityName)
log.info(`The timezone of ${cityName} (${countryCode}) is ${timeZone}`)
assertEquals('Europe/Berlin', timeZone)
});
Deno.test("get offset", async (): Promise<void> => {
const countryCode = 'DE'
const cityName = 'Heidelberg'
const offset = await TimeService.getTimeZoneOffset(countryCode, cityName)
log.info(`offset: ${offset}`)
const offsetInminutes = await TimeService.getTimeZoneOffset(countryCode, cityName, true)
log.info(`offset in minutes: ${offsetInminutes}`)
});
Deno.test("get daylight saving time offset", async (): Promise<void> => {
const countryCode = 'DE'
const cityName = 'Heidelberg'
const offsetDST = await TimeService.getTimeZoneOffsetDST(countryCode, cityName)
log.info(`offsetDST: ${offsetDST}`)
const offsetDSTInminutes = await TimeService.getTimeZoneOffsetDST(countryCode, cityName, true)
log.info(`offset daylight saving time in Minutes: ${offsetDSTInminutes}`)
});