+3
-5
@@ -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; | ||
| }; | ||
| } |
+36
-33
| { | ||
| "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" | ||
| } | ||
| } |
+8
-16
@@ -1,27 +0,25 @@ | ||
| # time-zone [](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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Yes
NaN2591
-5.27%8
-11.11%39
-17.02%