Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thlorenz/ntz
Normalizes timezone inside a date string to be convertible to a JavaScript Date.
https://github.com/thlorenz/ntz
Last synced: 24 days ago
JSON representation
Normalizes timezone inside a date string to be convertible to a JavaScript Date.
- Host: GitHub
- URL: https://github.com/thlorenz/ntz
- Owner: thlorenz
- License: mit
- Created: 2018-07-04T19:31:35.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-07T05:04:43.000Z (over 6 years ago)
- Last Synced: 2024-11-22T14:21:15.077Z (about 1 month ago)
- Language: JavaScript
- Homepage: https://github.com/thlorenz/ntz
- Size: 1.13 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ntz [![build status](https://secure.travis-ci.org/thlorenz/ntz.svg?branch=master)](http://travis-ci.org/thlorenz/ntz)
Normalizes timezone inside a date string to make it convertible to a JavaScript Date.
```js
const ntz = require('ntz')const original = 'Sunday, July 24, 19:32:00 CEST 2016'
console.log(new Date(original)) // => Invalid Dateconst normalized = ntz(original)
console.log(new Date(normalized))// => 2016-07-24T17:32:00.000Z
```## Installation
npm install ntz
## [API](https://thlorenz.github.io/ntz)
### ntz
Replaces timezone abbreviation like 'CDT' with the matching UTC offset
If no known timezone is encountered in the string, the original string is returned.**Parameters**
- `s` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** original date/time string
Returns **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** with timezone abbreviation replaced
## License
MIT