https://github.com/maxrimue/tizo
easily parse and convert any string containing hours, minutes and timezone
https://github.com/maxrimue/tizo
converter parser timezones
Last synced: 7 months ago
JSON representation
easily parse and convert any string containing hours, minutes and timezone
- Host: GitHub
- URL: https://github.com/maxrimue/tizo
- Owner: maxrimue
- License: mit
- Created: 2018-04-24T20:32:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-12-29T12:57:20.000Z (almost 6 years ago)
- Last Synced: 2025-03-18T14:58:02.470Z (7 months ago)
- Topics: converter, parser, timezones
- Language: TypeScript
- Size: 24.4 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# tizo [](https://travis-ci.com/maxrimue/tizo) [](https://greenkeeper.io/)
> convert a string with hours to any timezone
## Install
```
$ npm install tizo
```## Usage
```js
const tizo = require("tizo").default;
// or
import tizo from 'tizo';tizo("19:30 CEST").utc;
// → '[ 17, 30 ]'tizo("9pm").original;
// → '[ 21, 0 ]'tizo("08:21").local;
// → '[ 8 + local offset, 21 + local offset ]'
```- supports many different, popular timezones, including summer/winter adaptions
- automatically parses 'am' and 'pm' for time formatting
- doesn't require internet connection for any lookup
- flexible formatting (eg `sss01:02 aM CesT sss` → `[1, 2, 'am', 'cest']`)
- returns local, utc (gmt) and parsed time## API
### tizo(input)
#### input
Type: `string`
Any string containing at least a specific hour, and additionally minutes, and optionally am/pm and/or timezone
#### returns
Type `object`
##### original
Type: `array`
Original, parsed time in `[ hours, minutes ]`
#### utc
Type: `array`
UTC/GMT time in `[ hours, minutes ]`
#### local
Type: `array`
Local time in `[ hours, minutes ]`
#### timezones
Type: `object`
List of supported timezones in `: { offset: , name: }`.
See examples in the [timezones.ts](timezones.ts) file.- `timezone key`: abbreviated name of timezone, eg "cest"
- `offset`: positive or negative integer or [integer, integer] representing the timezone's offset
- `spelled out name`: full name of the timezone, eg "Central European Summer Time"## Related
- [tizo-cli](https://github.com/maxrimue/tizo-cli) - CLI version of this module
## License
MIT © [maxrimue](http://github.com/maxrimue)