Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/parse-zonetab
Parse zone.tab file
https://github.com/shinnn/parse-zonetab
Last synced: 26 days ago
JSON representation
Parse zone.tab file
- Host: GitHub
- URL: https://github.com/shinnn/parse-zonetab
- Owner: shinnn
- License: mit
- Created: 2016-06-15T11:02:07.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-08T05:23:08.000Z (over 8 years ago)
- Last Synced: 2024-04-24T20:14:18.576Z (7 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# parse-zonetab
[![NPM version](https://img.shields.io/npm/v/parse-zonetab.svg)](https://www.npmjs.com/package/parse-zonetab)
[![Build Status](https://travis-ci.org/shinnn/parse-zonetab.svg?branch=master)](https://travis-ci.org/shinnn/parse-zonetab)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/parse-zonetab.svg)](https://coveralls.io/github/shinnn/is-gist-starred?branch=master)
[![dependencies Status](https://david-dm.org/shinnn/parse-zonetab/status.svg)](https://david-dm.org/shinnn/parse-zonetab)
[![devDependencies Status](https://david-dm.org/shinnn/parse-zonetab/dev-status.svg)](https://david-dm.org/shinnn/parse-zonetab?type=dev)A [Node](https://nodejs.org/) module to parse [zone.tab](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) file
```javascript
const parseZonetab = require('parse-zonetab');const source = `
#
# tz zone descriptions
#
AD +4230+00131 Europe/Andorra
AE +2518+05518 Asia/Dubai
AF +3431+06912 Asia/Kabul
AG +1703-06148 America/Antigua
AI +1812-06304 America/Anguilla`;parseZonetab(source).then(rows => {
rows; /* => [
{
countryCode: 'AD',
coordinate: {
latitude: {sign: '+', degree: 42, minute: 30},
longitude: {sign: '+', degree: 1, minute: 31}
},
id: 'Europe/Andorra'
},
{
countryCode: 'AE',
coordinate: {
latitude: {sign: '+', degree: 25, minute: 18},
longitude: {sign: '+', degree: 55, minute: 18}
}
id: 'Asia/Dubai'
},
...
] */
});
```## Installation
[Use npm.](https://docs.npmjs.com/cli/install)
```
npm install parse-zonetab
```## API
```javascript
const parseZonetab = require('parse-zonetab');
```### parseZonetab(*source*)
*source*: [`Buffer`](https://nodejs.org/api/buffer.html#buffer_class_buffer), [`String`](http://www.ecma-international.org/ecma-262/5.1/#sec-4.3.17) or [`Stream`](https://nodejs.org/api/stream.html#stream_stream)
Return: [`Promise`](http://www.ecma-international.org/ecma-262/6.0/#sec-promise-constructor)It takes [`zone.tab`](https://www.iana.org/time-zones) file data and returns a promise for an array of parsed rows each of whom is in the form:
```
{
countryCode: ,
coordinate: {
latitude: {
sign: ('+' or '-'),
degree: ,
minute: ,
[second: ] (if available)
},
longitude: {
sign: ('+' or '-'),
degree: ,
minute: ,
[second: ] (if available)
}
},
id: ,
[comment: ] (if available)
}
```## Related project
* [get-zonetab](https://github.com/shinnn/get-zonetab) - get the latest `zone.tab` file form IANA Time Zone Database
## License
Copyright (c) 2016 [Shinnosuke Watanabe](https://github.com/shinnn)
Licensed under [the MIT License](./LICENSE).