Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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)

become a patron

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 Date

const 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