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

@waiting/shared-core

Package Overview
Dependencies
Maintainers
1
Versions
199
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@waiting/shared-core - npm Package Compare versions

Comparing version 23.0.2 to 23.1.0

3

dist/lib/date.d.ts

@@ -9,2 +9,5 @@ import { ISO8601String } from '@waiting/shared-types';

export declare function genISO8601String(date?: Date): ISO8601String;
export declare const defaultDateTimeFormatOptions: Intl.DateTimeFormatOptions;
export declare const dateTimeFormatterCN: Intl.DateTimeFormat;
export declare function formatDateTime(input: number | string | Date, locales?: string | string[], options?: Intl.DateTimeFormatOptions): any;
//# sourceMappingURL=date.d.ts.map

@@ -26,2 +26,33 @@ /**

}
export const defaultDateTimeFormatOptions = {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
timeZone: 'Asia/Shanghai',
};
export const dateTimeFormatterCN = new Intl.DateTimeFormat('zh-CN', defaultDateTimeFormatOptions);
// const date = new Date(Date.UTC(2020, 11, 20, 3, 23, 16, 738))
// dateFormatterCN.format(date) // "2020/12/20 11:23:16"
export function formatDateTime(input, locales = 'zh-CN', options) {
const dateFormatter = locales && options
? new Intl.DateTimeFormat(locales, options)
: dateTimeFormatterCN;
if (input instanceof Date) {
return dateFormatter.format(input);
}
else if (typeof input === 'number') {
const val = new Date(input);
return dateFormatter.format(val);
}
else if (typeof input === 'string') {
const val = new Date(input);
return dateFormatter.format(val);
}
else {
throw new Error('input is invalid');
}
}
//# sourceMappingURL=date.js.map

4

package.json
{
"name": "@waiting/shared-core",
"author": "waiting",
"version": "23.0.2",
"version": "23.1.0",
"description": "node core function re export with Promise or Observable",

@@ -77,3 +77,3 @@ "keywords": [

},
"gitHead": "557438667960683a01d6c720e29ebc4a559b61e2"
"gitHead": "d1e6ffd6ca253e27f5aabd6a70554f35c3fd5587"
}

@@ -0,1 +1,2 @@

/* eslint-disable @typescript-eslint/no-explicit-any */
import { ISO8601String } from '@waiting/shared-types'

@@ -33,1 +34,44 @@

export const defaultDateTimeFormatOptions: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
timeZone: 'Asia/Shanghai',
}
export const dateTimeFormatterCN = new Intl.DateTimeFormat('zh-CN', defaultDateTimeFormatOptions)
// const date = new Date(Date.UTC(2020, 11, 20, 3, 23, 16, 738))
// dateFormatterCN.format(date) // "2020/12/20 11:23:16"
export function formatDateTime(
input: number | string | Date,
locales: string | string[] = 'zh-CN',
options?: Intl.DateTimeFormatOptions,
): any {
const dateFormatter = locales && options
? new Intl.DateTimeFormat(locales, options)
: dateTimeFormatterCN
if (input instanceof Date) {
return dateFormatter.format(input)
}
else if (typeof input === 'number') {
const val = new Date(input)
return dateFormatter.format(val)
}
else if (typeof input === 'string') {
const val = new Date(input)
return dateFormatter.format(val)
}
else {
throw new Error('input is invalid')
}
}

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