-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(extracted-tz-data): add location and geographic area to the extr…
…acted timezone data
1 parent
3d01dc4
commit 82f8c0d
Showing
4 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export function extractGeographicAreaAndLocation(input: string): {geographicArea: string, location: string} { | ||
const firstSlash = input.indexOf('/'); | ||
const geographicArea = input.slice(0, firstSlash); | ||
// + 1 (don't actually copy the first slash) | ||
const location = input.slice(firstSlash + 1, input.length); | ||
return {geographicArea, location} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// From the IANA timezone theory file | ||
// Names normally have the form AREA/LOCATION, | ||
// where AREA is the name of a continent or ocean, | ||
// and LOCATION is the name of a specific location within that region. | ||
// North and South America share the same area, 'America'. | ||
// Typical names are 'Africa/Cairo', 'America/New_York', and 'Pacific/Honolulu'. | ||
|
||
import {extractGeographicAreaAndLocation} from './extract-geographic-area-and-location'; | ||
|
||
describe('extract geographic area and location', () => { | ||
it('should extract geographic area and location from a two parameter tz', () => { | ||
const {geographicArea, location} = extractGeographicAreaAndLocation('Europe/Andorra'); | ||
|
||
expect(geographicArea).toEqual('Europe'); | ||
expect(location).toEqual('Andorra') | ||
}); | ||
|
||
it('should extract geographic area and location from a three parameter tz', () =>{ | ||
const {geographicArea, location} = extractGeographicAreaAndLocation('America/Argentina/Buenos_Aires'); | ||
|
||
expect(geographicArea).toEqual('America'); | ||
expect(location).toEqual('Argentina/Buenos_Aires') | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters