🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

time-zone

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

time-zone - npm Package Compare versions

Comparing version
1.0.0
to
2.0.0
+3
-5
index.js

@@ -1,4 +0,3 @@

'use strict';
module.exports = date => {
const offset = (date || new Date()).getTimezoneOffset();
export default function timeZone(date = new Date()) {
const offset = date.getTimezoneOffset();
const absOffset = Math.abs(offset);

@@ -8,4 +7,3 @@ const hours = Math.floor(absOffset / 60);

const minutesOut = minutes > 0 ? ':' + ('0' + minutes).slice(-2) : '';
return (offset < 0 ? '+' : '-') + hours + minutesOut;
};
}
{
"name": "time-zone",
"version": "1.0.0",
"description": "Pretty time zone: `+2` or `-9:30`",
"license": "MIT",
"repository": "sindresorhus/time-zone",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"timezone",
"utc",
"time",
"pretty",
"human",
"date",
"iso",
"zone"
],
"devDependencies": {
"ava": "*",
"xo": "*"
}
"name": "time-zone",
"version": "2.0.0",
"description": "Pretty time zone: `+2` or `-9:30`",
"license": "MIT",
"repository": "sindresorhus/time-zone",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=12"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"timezone",
"utc",
"time",
"pretty",
"human",
"date",
"iso",
"zone"
],
"devDependencies": {
"ava": "^3.15.0",
"xo": "^0.38.2"
}
}

@@ -1,27 +0,25 @@

# time-zone [![Build Status](https://travis-ci.org/sindresorhus/time-zone.svg?branch=master)](https://travis-ci.org/sindresorhus/time-zone)
# time-zone
> Pretty [time zone](https://en.wikipedia.org/wiki/Time_zone): `+2` or `-9:30`
## Install
```
$ npm install --save time-zone
$ npm install time-zone
```
## Usage
```js
const timeZone = require('time-zone');
import timeZone from 'time-zone';
// current time zone (in Norway)
// Current time zone (in Norway)
timeZone();
//=> '+2'
// time zone in February (in Norway)
// Time zone in February (in Norway)
timeZone(new Date(2016, 1, 1));
//=> '+1'
// current time zone (in French Polynesia)
// Current time zone (in French Polynesia)
timeZone();

@@ -31,17 +29,11 @@ //=> '-9:30'

## API
### timeZone([date])
### timeZone(date?)
#### date
Type: `Date`<br>
Type: `Date`\
Default: `new Date()`
Custom date.
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

Sorry, the diff of this file is not supported yet