mirror of https://github.com/iptv-org/iptv
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
664 B
TypeScript
31 lines
664 B
TypeScript
import { Collection, Dictionary } from '@freearhey/core'
|
|
|
|
type TimezoneData = {
|
|
id: string
|
|
utc_offset: string
|
|
countries: string[]
|
|
}
|
|
|
|
export class Timezone {
|
|
id: string
|
|
utcOffset: string
|
|
countryCodes: Collection
|
|
countries?: Collection
|
|
|
|
constructor(data: TimezoneData) {
|
|
this.id = data.id
|
|
this.utcOffset = data.utc_offset
|
|
this.countryCodes = new Collection(data.countries)
|
|
}
|
|
|
|
withCountries(countriesGroupedByCode: Dictionary): this {
|
|
this.countries = this.countryCodes.map((code: string) => countriesGroupedByCode.get(code))
|
|
|
|
return this
|
|
}
|
|
|
|
getCountries(): Collection {
|
|
return this.countries || new Collection()
|
|
}
|
|
}
|