Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dayjs-abbr-timezone

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

dayjs-abbr-timezone - npm Package Compare versions

Comparing version 0.0.3 to 1.0.0

7

dist/main.js

@@ -21,9 +21,10 @@ var $8zHUo$timezonesjson = require("timezones.json");

dayjsClass.prototype.format = function(template) {
const result = template?.replace(/\[([^\]]+)]|tz/g, (match)=>{
const result = template?.replace(/\[([^\]]+)]|t/g, (match)=>{
switch(match){
case "tz":
case "t":
{
const unabbrZoneName = this.offsetName("long");
const timezone = (0, ($parcel$interopDefault($8zHUo$timezonesjson))).find((tz)=>tz.value === unabbrZoneName);
return timezone?.abbr ?? match;
if (timezone) return `[${timezone.abbr}]`;
return `[${this.offsetName() ?? match}]`;
}

@@ -30,0 +31,0 @@ default:

@@ -7,9 +7,10 @@ import $hgUW1$timezonesjson from "timezones.json";

dayjsClass.prototype.format = function(template) {
const result = template?.replace(/\[([^\]]+)]|tz/g, (match)=>{
const result = template?.replace(/\[([^\]]+)]|t/g, (match)=>{
switch(match){
case "tz":
case "t":
{
const unabbrZoneName = this.offsetName("long");
const timezone = (0, $hgUW1$timezonesjson).find((tz)=>tz.value === unabbrZoneName);
return timezone?.abbr ?? match;
if (timezone) return `[${timezone.abbr}]`;
return `[${this.offsetName() ?? match}]`;
}

@@ -16,0 +17,0 @@ default:

{
"name": "dayjs-abbr-timezone",
"description": "A plugin for day.js that extends the 'format' function, enabling the correct output of abbreviated timezones instead of the standard GMT display.",
"version": "0.0.3",
"version": "1.0.0",
"author": "kyushun <mail@kyushun.com>",

@@ -28,2 +28,3 @@ "license": "MIT",

"scripts": {
"clean": "rimraf dist .parcel-cache",
"watch": "parcel watch",

@@ -37,5 +38,5 @@ "build": "parcel build",

"@parcel/transformer-typescript-types": "2.9.2",
"@types/jest": "^29.5.2",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"@typescript-eslint/parser": "^5.59.11",
"@types/jest": "^29.5.2",
"eslint": "^8.42.0",

@@ -48,2 +49,3 @@ "eslint-config-airbnb-base": "^15.0.0",

"prettier": "^2.8.8",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.0",

@@ -50,0 +52,0 @@ "typescript": "^5.1.3"

@@ -5,3 +5,3 @@ # dayjs-abbr-timezone

For instance, when the timezone is set to Asia/Tokyo, the `z` format would usually output GMT+9. However, with this plugin, you can use the `tz` format to output JST correctly.
For instance, when the timezone is set to Asia/Tokyo, the `z` format would usually output GMT+9. However, with this plugin, you can use the `t` format to output JST correctly.

@@ -16,16 +16,20 @@ ## Installation

To use the plugin, first import it into your file:
This plugin depends on the `utc` and `timezone` plugins of Day.js. Please ensure you've imported and extended them as follows:
```typescript
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
import abbrTimezone from 'dayjs-abbr-timezone';
dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.extend(abbrTimezone);
```
Then you can use the format function with the `tz` option:
Then you can use the format function with the `t` option:
```typescript
const date = dayjs('2023-01-01T12:00:00Z');
console.log(date.format('YYYY-MM-DD HH:mm:ss tz'));
const date = dayjs('2023-01-01T12:00:00Z').tz('Asia/Tokyo');
console.log(date.format('YYYY-MM-DD HH:mm:ss t')); // 2023-01-01 21:00:00 JST
```

@@ -32,0 +36,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc