Comparing version
@@ -1,2 +0,117 @@ | ||
declare function _exports(...args: any[]): any; | ||
export = _exports; | ||
// TypeScript Version: 2.9 | ||
/** | ||
* Translates the given text. | ||
* @param text Text to translate | ||
* @param defaultNumOrFormatting Number OR formatting to use in translation | ||
* @param numOrFormattingOrContext Number OR formatting OR context to use in translation | ||
* @param formattingOrContext Format OR context to use in translation | ||
* @param context Context to be used when translating | ||
*/ | ||
declare function i18n(text: string | number, | ||
defaultNumOrFormatting?: number | i18n.FormattingContext, | ||
numOrFormattingOrContext?: number | i18n.FormattingContext, | ||
formattingOrContext?: i18n.FormattingContext, | ||
context?: i18n.FormattingContext): string; | ||
declare namespace i18n { | ||
interface Values { | ||
[index: string]: string | Array<string | Array<string | number | null>> | {[key: string]: string}; | ||
} | ||
interface FormattingContext { | ||
[key: string]: string; | ||
} | ||
interface ContextOpts { | ||
matches: FormattingContext; | ||
values: Values; | ||
} | ||
interface DataOpts { | ||
values?: Values; | ||
contexts?: ContextOpts[]; | ||
} | ||
namespace translator { | ||
namespace constructor { | ||
let name: string; | ||
} | ||
/** | ||
* Translates the given text. | ||
* @param text Text to translate | ||
* @param defaultNumOrFormatting Number OR formatting to use in translation | ||
* @param numOrFormattingOrContext Number OR formatting OR context to use in translation | ||
* @param formattingOrContext Format OR context to use in translation | ||
* @param context Context to use in translation | ||
*/ | ||
function translate(text: string | number, | ||
defaultNumOrFormatting?: number | FormattingContext, | ||
numOrFormattingOrContext?: number | FormattingContext, | ||
formattingOrContext?: FormattingContext, | ||
context?: FormattingContext): string; | ||
/** | ||
* Adds data (values and contexts) to i18n instance. | ||
* @param data The language data: { "values": { "Yes": "はい", "No": "いいえ" } } | ||
*/ | ||
function add(data: DataOpts | object): void; // object is an alternate parameter type to allow imports from JSON files | ||
/** | ||
* Sets the context globally. This context will be used when translating all strings unless a different context is provided when calling i18n(). | ||
* @param key The key for the context, e.g. "gender". | ||
* @param value The value for the context, e.g. "female". | ||
*/ | ||
function setContext(key: string, | ||
value: string): void; | ||
/** | ||
* Adds extension to i18n instance. | ||
* @param ext Extension to add | ||
*/ | ||
function extend(ext: (text: string, | ||
number: number, | ||
formatting: FormattingContext, | ||
data: Values) => string | number): void; | ||
/** | ||
* Clears the context for the given key. | ||
* @param key The key to clear | ||
*/ | ||
function clearContext(key: string): void; | ||
/** | ||
* Destroys all translation and context data. | ||
*/ | ||
function reset(): void; | ||
/** | ||
* Destroys all translation data. Useful for when you change languages. | ||
*/ | ||
function resetData(): void; | ||
/** | ||
* Destroys all context data. | ||
*/ | ||
function resetContext(): void; | ||
/** | ||
* Translates all the keys in a hash. Useful for translating the i18n property that exists for some lovely.io packages. | ||
* @param hash Hash containing the strings to be translated. | ||
* @param context Context to be used when translating the hash values. | ||
*/ | ||
function translateHash(hash: {[key: string]: string}, | ||
context?: FormattingContext): object; | ||
let data: DataOpts; | ||
} | ||
/** | ||
* Creates a new i18n instance. | ||
* @param data Data to add to new i18n instance | ||
*/ | ||
function create(data?: DataOpts | object): typeof i18n; | ||
} | ||
export = i18n; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -1,14 +0,37 @@ | ||
export class LocaleHolder { | ||
static initValues(): void; | ||
static setLocale(language: any, formattingLocale: any): Promise<void>; | ||
static getDateFormat(showYear: any): any; | ||
static getDateTimeFormat(showYear: any, showSeconds: any, showMillis: any): any; | ||
static getTimeFormat(showSeconds: any, showMillis: any): any; | ||
static formatNumber(value: any, fractionDigits: any, omitGrouping: any): any; | ||
static getNumberFormatter(fractionDigits: any, omitGrouping: any): any; | ||
static parseNumber(text: any, fractionDigits: any): void; | ||
static getDecimalSeparator(locale: any): string; | ||
static getGroupSeparator(locale: any): string; | ||
static formatBytes(bytes: any, decimals?: number): string; | ||
static getDurationFormat(showDays: any, showMillis: any): string; | ||
declare namespace localeHolder { | ||
type LanguageIsoCode = "en" | "sk" | "cs" | "ru" | "kk" | "sr" | "uk"; | ||
class LocaleHolder { | ||
static setLocale: (language: LanguageIsoCode, formattingLocale?: string) => Promise<void> | ||
static locale: LanguageIsoCode | ||
static uiLocale: any | undefined | ||
static localeData: any | undefined | ||
static formattingLocale: string | ||
static decimalSeparator: string | ||
static groupSeparator: string | ||
static formatNumber(value: number, fractionDigits?: number, omitGrouping?: boolean): string | ||
static formatBytes(bytes: number, decimals: number): string | ||
static getNumberFormatter(fractionDigits: number, useGrouping?: boolean): { | ||
format(value: number): string | ||
} | ||
static getDateFormat(showYear?: boolean): string | ||
static getDateTimeFormat(showYear?: boolean, showSeconds?: boolean, showMillis?: boolean): string | ||
static getTimeFormat(showSeconds?: boolean, showMillis?: boolean): string | ||
static getDurationFormat(showDays?: boolean, showMillis?: boolean): string | ||
} | ||
} | ||
export = localeHolder; |
@@ -1,3 +0,2 @@ | ||
import moment from "moment"; | ||
import momentDurationFormatSetup from "moment-duration-format"; | ||
import dayjs from "d2core/dayjs"; | ||
import parseDecimalNumber from "parse-decimal-number"; | ||
@@ -8,2 +7,3 @@ export class LocaleHolder { | ||
LocaleHolder.uiLocale = undefined; | ||
LocaleHolder.localeData = undefined; | ||
LocaleHolder.formattingLocale = "en-GB"; | ||
@@ -33,23 +33,23 @@ LocaleHolder.decimalSeparator = "."; | ||
uiLocalePromise = import("antd/es/locale/sk_SK"); | ||
momentLocalePromise = import("moment/locale/sk"); | ||
momentLocalePromise = import("dayjs/locale/sk"); | ||
} | ||
else if (language === "cs") { | ||
uiLocalePromise = import("antd/es/locale/cs_CZ"); | ||
momentLocalePromise = import("moment/locale/cs"); | ||
momentLocalePromise = import("dayjs/locale/cs"); | ||
} | ||
else if (language === "uk") { | ||
uiLocalePromise = import("antd/es/locale/uk_UA"); | ||
momentLocalePromise = import("moment/locale/uk"); | ||
momentLocalePromise = import("dayjs/locale/uk"); | ||
} | ||
else if (language === "ru") { | ||
uiLocalePromise = import("antd/es/locale/ru_RU"); | ||
momentLocalePromise = import("moment/locale/ru"); | ||
momentLocalePromise = import("dayjs/locale/ru"); | ||
} | ||
else if (language === "kk") { | ||
uiLocalePromise = import("antd/es/locale/ru_RU"); | ||
momentLocalePromise = import("moment/locale/kk"); | ||
momentLocalePromise = import("dayjs/locale/kk"); | ||
} | ||
else if (language === "sr") { | ||
uiLocalePromise = import("antd/es/locale/sr_RS"); | ||
momentLocalePromise = import("moment/locale/sr"); | ||
momentLocalePromise = import("dayjs/locale/sr"); | ||
} | ||
@@ -59,9 +59,8 @@ else { | ||
} | ||
momentDurationFormatSetup(moment); | ||
LocaleHolder.formattingLocale = formattingLocale ? formattingLocale : language; | ||
if (momentLocalePromise) { | ||
await momentLocalePromise; | ||
moment.locale(LocaleHolder.formattingLocale); | ||
LocaleHolder.localeData = (await momentLocalePromise).default; | ||
dayjs.locale(LocaleHolder.formattingLocale); | ||
} | ||
const localeData = moment.localeData(); | ||
const localeData = dayjs.localeData(); | ||
LocaleHolder.formatHourMin = localeData.longDateFormat(`LT`); | ||
@@ -68,0 +67,0 @@ if (LocaleHolder.formatHourMin.indexOf("HH") < 0) { |
{ | ||
"name": "d2core", | ||
"version": "21.0.7", | ||
"version": "23.0.0-sds", | ||
"description": "Core types and utilities library.", | ||
"author": "Ipesoft s.r.o.", | ||
"license": "MIT", | ||
"dependencies": { | ||
"moment": "2.25.3", | ||
"moment-duration-format": "2.3.2" | ||
"peerDependencies": { | ||
"dayjs": "1.x" | ||
}, | ||
@@ -14,7 +13,9 @@ "scripts": { | ||
"copyPackageJson": "@powershell copy './package.json' './lib/esm/'", | ||
"copyDTs": "yarn copyfiles \"./**/*.d.ts\" ./lib/esm/", | ||
"build": "tsc -P tsconfig.build.json", | ||
"publish-lib": "yarn cleanBuild && yarn build && yarn copyPackageJson && yarn publish ./lib/esm", | ||
"build-copy": "yarn cleanBuild && yarn build && yarn copyDTs && yarn copyPackageJson", | ||
"publish-lib": "yarn build-copy && yarn publish ./lib/esm", | ||
"publish-beta": "npm run build && npm publish --tag beta", | ||
"publish-dryrun": "npm run build && npm publish --dry-run" | ||
"publish-dryrun": "yarn build-copy && yarn publish ./lib/esm --dry-run" | ||
} | ||
} |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ export declare const enum DataChangeStateEnum { |
@@ -0,0 +0,0 @@ export var DataChangeStateEnum; |
@@ -0,0 +0,0 @@ import { TimeInterval } from "./timeInterval"; |
@@ -1,4 +0,4 @@ | ||
import moment from "moment"; | ||
import dayjs from "d2core/dayjs"; | ||
function startEnergyWeek() { | ||
return moment().day() === 6 ? moment().startOf('day') : moment().startOf('day').subtract(1 + moment().day(), 'day'); | ||
return dayjs().day() === 6 ? dayjs().startOf('day') : dayjs().startOf('day').subtract(1 + dayjs().day(), 'day'); | ||
} | ||
@@ -9,3 +9,3 @@ export const DateTimeInterval = { | ||
interval: () => { | ||
return [moment().subtract(1, 'hours'), moment()]; | ||
return [dayjs().subtract(1, 'hours'), dayjs()]; | ||
}, | ||
@@ -18,3 +18,3 @@ period: [1, 'hours'], | ||
interval: () => { | ||
return [moment().startOf('hour'), moment().endOf("hour")]; | ||
return [dayjs().startOf('hour'), dayjs().endOf("hour")]; | ||
}, | ||
@@ -27,3 +27,3 @@ period: [1, 'hours'], | ||
interval: () => { | ||
return [moment().subtract(1, 'hours').startOf('hours'), moment().endOf("hour")]; | ||
return [dayjs().subtract(1, 'hours').startOf('hours'), dayjs().endOf("hour")]; | ||
}, | ||
@@ -36,3 +36,3 @@ period: [2, 'hours'], | ||
interval: () => { | ||
return [moment().subtract(7, 'hours').startOf('hours'), moment().endOf("hour")]; | ||
return [dayjs().subtract(7, 'hours').startOf('hours'), dayjs().endOf("hour")]; | ||
}, | ||
@@ -45,3 +45,3 @@ period: [8, 'hours'], | ||
interval: () => { | ||
return [moment().subtract(11, 'hours').startOf('hours'), moment().endOf("hour")]; | ||
return [dayjs().subtract(11, 'hours').startOf('hours'), dayjs().endOf("hour")]; | ||
}, | ||
@@ -54,3 +54,3 @@ period: [12, 'hours'], | ||
interval: () => { | ||
return [moment().subtract(23, 'hours').startOf('hours'), moment().endOf("hour")]; | ||
return [dayjs().subtract(23, 'hours').startOf('hours'), dayjs().endOf("hour")]; | ||
}, | ||
@@ -63,3 +63,3 @@ period: [24, 'hours'], | ||
interval: () => { | ||
return [moment().subtract(1, 'hours').startOf('hours'), moment().subtract(1, 'hours').endOf('hour')]; | ||
return [dayjs().subtract(1, 'hours').startOf('hours'), dayjs().subtract(1, 'hours').endOf('hour')]; | ||
}, | ||
@@ -72,3 +72,3 @@ period: [1, 'hours'], | ||
interval: () => { | ||
return [moment().subtract(1, 'day'), moment()]; | ||
return [dayjs().subtract(1, 'day'), dayjs()]; | ||
}, | ||
@@ -81,3 +81,3 @@ period: [1, 'day'], | ||
interval: () => { | ||
return [moment().startOf('day'), moment().endOf("day")]; | ||
return [dayjs().startOf('day'), dayjs().endOf("day")]; | ||
}, | ||
@@ -90,3 +90,3 @@ period: [1, 'day'], | ||
interval: () => { | ||
return [moment().subtract(1, 'day').startOf('day'), moment().subtract(1, 'day').endOf('day')]; | ||
return [dayjs().subtract(1, 'day').startOf('day'), dayjs().subtract(1, 'day').endOf('day')]; | ||
}, | ||
@@ -99,3 +99,3 @@ period: [1, 'day'], | ||
interval: () => { | ||
return [moment().hour() < 6 ? moment().subtract(1, 'day').startOf('day').add(6, 'hour') : moment().startOf('day').add(6, 'hour'), moment().hour() < 6 ? moment().startOf('day').add(6, 'hour').subtract(1, 'second') : moment().add(1, 'day').startOf('day').add(6, 'hour').subtract(1, 'second')]; | ||
return [dayjs().hour() < 6 ? dayjs().subtract(1, 'day').startOf('day').add(6, 'hour') : dayjs().startOf('day').add(6, 'hour'), dayjs().hour() < 6 ? dayjs().startOf('day').add(6, 'hour').subtract(1, 'second') : dayjs().add(1, 'day').startOf('day').add(6, 'hour').subtract(1, 'second')]; | ||
}, | ||
@@ -108,3 +108,3 @@ period: [1, 'day'], | ||
interval: () => { | ||
return [moment().subtract(1, 'day').hour() < 6 ? moment().subtract(2, 'day').startOf('day').add(6, 'hour') : moment().subtract(1, 'day').startOf('day').add(6, 'hour'), moment().subtract(1, 'day').hour() < 6 ? moment().subtract(1, 'day').startOf('day').add(6, 'hour').subtract(1, 'second') : moment().startOf('day').add(6, 'hour').subtract(1, 'second')]; | ||
return [dayjs().subtract(1, 'day').hour() < 6 ? dayjs().subtract(2, 'day').startOf('day').add(6, 'hour') : dayjs().subtract(1, 'day').startOf('day').add(6, 'hour'), dayjs().subtract(1, 'day').hour() < 6 ? dayjs().subtract(1, 'day').startOf('day').add(6, 'hour').subtract(1, 'second') : dayjs().startOf('day').add(6, 'hour').subtract(1, 'second')]; | ||
}, | ||
@@ -117,3 +117,3 @@ period: [1, 'day'], | ||
interval: () => { | ||
return [moment().subtract(24, 'hours'), moment()]; | ||
return [dayjs().subtract(24, 'hours'), dayjs()]; | ||
}, | ||
@@ -126,3 +126,3 @@ period: [24, 'hours'], | ||
interval: () => { | ||
return [moment().subtract(12, 'hours'), moment()]; | ||
return [dayjs().subtract(12, 'hours'), dayjs()]; | ||
}, | ||
@@ -135,3 +135,3 @@ period: [12, 'hours'], | ||
interval: () => { | ||
return [moment().hour() < 12 ? moment().startOf('day') : moment().startOf('day').add(12, 'hour'), moment().hour() < 12 ? moment().startOf('day').add(12, 'hour').subtract(1, 'second') : moment().endOf('day')]; | ||
return [dayjs().hour() < 12 ? dayjs().startOf('day') : dayjs().startOf('day').add(12, 'hour'), dayjs().hour() < 12 ? dayjs().startOf('day').add(12, 'hour').subtract(1, 'second') : dayjs().endOf('day')]; | ||
}, | ||
@@ -144,3 +144,3 @@ period: [12, 'hours'], | ||
interval: () => { | ||
return [moment().subtract(12, 'hours').hour() < 12 ? moment().subtract(12, 'hours').startOf('day') : moment().subtract(12, 'hours').startOf('day').add(12, 'hour'), moment().subtract(12, 'hours').hour() < 12 ? moment().subtract(12, 'hours').startOf('day').add(12, 'hour').subtract(1, 'second') : moment().subtract(12, 'hours').endOf('day')]; | ||
return [dayjs().subtract(12, 'hours').hour() < 12 ? dayjs().subtract(12, 'hours').startOf('day') : dayjs().subtract(12, 'hours').startOf('day').add(12, 'hour'), dayjs().subtract(12, 'hours').hour() < 12 ? dayjs().subtract(12, 'hours').startOf('day').add(12, 'hour').subtract(1, 'second') : dayjs().subtract(12, 'hours').endOf('day')]; | ||
}, | ||
@@ -153,3 +153,3 @@ period: [12, 'hours'], | ||
interval: () => { | ||
return [moment().subtract(8, 'hours'), moment()]; | ||
return [dayjs().subtract(8, 'hours'), dayjs()]; | ||
}, | ||
@@ -162,3 +162,3 @@ period: [8, 'hours'], | ||
interval: () => { | ||
return [moment().subtract(6, 'hours'), moment()]; | ||
return [dayjs().subtract(6, 'hours'), dayjs()]; | ||
}, | ||
@@ -171,3 +171,3 @@ period: [6, 'hours'], | ||
interval: () => { | ||
return [moment().hour() < 6 ? moment().startOf('day') : (moment().hour() < 12 ? moment().startOf('day').add(6, 'hour') : (moment().hour() < 18 ? moment().startOf('day').add(12, 'hour') : moment().startOf('day').add(18, 'hour'))), moment().hour() < 6 ? moment().startOf('day').add(6, 'hour').subtract(1, 'second') : (moment().hour() < 12 ? moment().startOf('day').add(12, 'hour').subtract(1, 'second') : (moment().hour() < 18 ? moment().startOf('day').add(18, 'hour').subtract(1, 'second') : moment().endOf('day')))]; | ||
return [dayjs().hour() < 6 ? dayjs().startOf('day') : (dayjs().hour() < 12 ? dayjs().startOf('day').add(6, 'hour') : (dayjs().hour() < 18 ? dayjs().startOf('day').add(12, 'hour') : dayjs().startOf('day').add(18, 'hour'))), dayjs().hour() < 6 ? dayjs().startOf('day').add(6, 'hour').subtract(1, 'second') : (dayjs().hour() < 12 ? dayjs().startOf('day').add(12, 'hour').subtract(1, 'second') : (dayjs().hour() < 18 ? dayjs().startOf('day').add(18, 'hour').subtract(1, 'second') : dayjs().endOf('day')))]; | ||
}, | ||
@@ -180,3 +180,3 @@ period: [6, 'hours'], | ||
interval: () => { | ||
return [moment().subtract(6, 'hours').hour() < 6 ? moment().subtract(6, 'hours').startOf('day') : (moment().subtract(6, 'hours').hour() < 12 ? moment().subtract(6, 'hours').startOf('day').add(6, 'hour') : (moment().subtract(6, 'hours').hour() < 18 ? moment().subtract(6, 'hours').startOf('day').add(12, 'hour') : moment().subtract(6, 'hours').startOf('day').add(18, 'hour'))), moment().subtract(6, 'hours').hour() < 6 ? moment().subtract(6, 'hours').startOf('day').add(6, 'hour').subtract(1, 'second') : (moment().subtract(6, 'hours').hour() < 12 ? moment().subtract(6, 'hours').startOf('day').add(12, 'hour').subtract(1, 'second') : (moment().hour() < 18 ? moment().subtract(6, 'hours').startOf('day').add(18, 'hour').subtract(1, 'second') : moment().subtract(6, 'hours').endOf('day')))]; | ||
return [dayjs().subtract(6, 'hours').hour() < 6 ? dayjs().subtract(6, 'hours').startOf('day') : (dayjs().subtract(6, 'hours').hour() < 12 ? dayjs().subtract(6, 'hours').startOf('day').add(6, 'hour') : (dayjs().subtract(6, 'hours').hour() < 18 ? dayjs().subtract(6, 'hours').startOf('day').add(12, 'hour') : dayjs().subtract(6, 'hours').startOf('day').add(18, 'hour'))), dayjs().subtract(6, 'hours').hour() < 6 ? dayjs().subtract(6, 'hours').startOf('day').add(6, 'hour').subtract(1, 'second') : (dayjs().subtract(6, 'hours').hour() < 12 ? dayjs().subtract(6, 'hours').startOf('day').add(12, 'hour').subtract(1, 'second') : (dayjs().hour() < 18 ? dayjs().subtract(6, 'hours').startOf('day').add(18, 'hour').subtract(1, 'second') : dayjs().subtract(6, 'hours').endOf('day')))]; | ||
}, | ||
@@ -189,3 +189,3 @@ period: [6, 'hours'], | ||
interval: () => { | ||
return [moment().subtract(1, 'week'), moment()]; | ||
return [dayjs().subtract(1, 'week'), dayjs()]; | ||
}, | ||
@@ -198,3 +198,3 @@ period: [1, 'week'], | ||
interval: () => { | ||
return [moment().startOf('isoWeek'), moment().endOf("isoWeek")]; | ||
return [dayjs().startOf('isoWeek'), dayjs().endOf("isoWeek")]; | ||
}, | ||
@@ -207,3 +207,3 @@ period: [1, 'week'], | ||
interval: () => { | ||
return [moment().subtract(6, 'day').startOf('isoWeek'), moment().subtract(6, 'day').endOf('isoWeek')]; | ||
return [dayjs().subtract(6, 'day').startOf('isoWeek'), dayjs().subtract(6, 'day').endOf('isoWeek')]; | ||
}, | ||
@@ -216,3 +216,3 @@ period: [1, 'week'], | ||
interval: () => { | ||
return [moment(startEnergyWeek()), moment(startEnergyWeek()).add(6, 'days').endOf("day")]; | ||
return [dayjs(startEnergyWeek()), dayjs(startEnergyWeek()).add(6, 'days').endOf("day")]; | ||
}, | ||
@@ -225,3 +225,3 @@ period: [1, 'week'], | ||
interval: () => { | ||
return [moment(startEnergyWeek()).subtract(7, 'day'), moment(startEnergyWeek()).subtract(1, 'second')]; | ||
return [dayjs(startEnergyWeek()).subtract(7, 'day'), dayjs(startEnergyWeek()).subtract(1, 'second')]; | ||
}, | ||
@@ -234,3 +234,3 @@ period: [1, 'week'], | ||
interval: () => { | ||
return [moment().subtract(1, 'month'), moment()]; | ||
return [dayjs().subtract(1, 'month'), dayjs()]; | ||
}, | ||
@@ -243,3 +243,3 @@ period: [1, 'month'], | ||
interval: () => { | ||
return [moment().startOf('month'), moment().endOf('month')]; | ||
return [dayjs().startOf('month'), dayjs().endOf('month')]; | ||
}, | ||
@@ -252,3 +252,3 @@ period: [1, 'month'], | ||
interval: () => { | ||
return [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]; | ||
return [dayjs().subtract(1, 'month').startOf('month'), dayjs().subtract(1, 'month').endOf('month')]; | ||
}, | ||
@@ -261,3 +261,3 @@ period: [1, 'month'], | ||
interval: () => { | ||
return [moment().subtract(1, 'year'), moment()]; | ||
return [dayjs().subtract(1, 'year'), dayjs()]; | ||
}, | ||
@@ -270,3 +270,3 @@ period: [1, 'year'], | ||
interval: () => { | ||
return [moment().startOf('year'), moment().endOf("year")]; | ||
return [dayjs().startOf('year'), dayjs().endOf("year")]; | ||
}, | ||
@@ -279,3 +279,3 @@ period: [1, 'year'], | ||
interval: () => { | ||
return [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year').endOf('year')]; | ||
return [dayjs().subtract(1, 'year').startOf('year'), dayjs().subtract(1, 'year').endOf('year')]; | ||
}, | ||
@@ -282,0 +282,0 @@ period: [1, 'year'], |
@@ -1,7 +0,6 @@ | ||
import moment, { Moment } from "moment"; | ||
import Base = moment.unitOfTime.Base; | ||
import { Dayjs, OpUnitType } from "dayjs"; | ||
export interface TimeInterval { | ||
id: string; | ||
interval?(): [Moment, Moment]; | ||
period?: [number, Base]; | ||
interval?(): [Dayjs, Dayjs]; | ||
period?: [number, OpUnitType]; | ||
alignMode?: AlignMode; | ||
@@ -8,0 +7,0 @@ } |
@@ -0,0 +0,0 @@ export var AlignMode; |
@@ -1,2 +0,2 @@ | ||
export declare type UnixTime = number; | ||
export type UnixTime = number; | ||
export declare const enum UnixTimeConversionEnum { | ||
@@ -3,0 +3,0 @@ FROM_SECONDS = "FROM_SECONDS", |
@@ -0,0 +0,0 @@ export var UnixTimeConversionEnum; |
@@ -1,5 +0,5 @@ | ||
import { Moment } from "moment/moment"; | ||
import { Dayjs } from "dayjs"; | ||
import { UnixTime, UnixTimeConversionEnum } from "./unixTime"; | ||
export declare let D2000UnixTimeNullValue: number; | ||
export declare let unixTimeToMoment: (value: UnixTime) => Moment; | ||
export declare let unixTimeToMoment: (value: UnixTime) => Dayjs; | ||
export declare function setUnixTimeConversion(conversionType: UnixTimeConversionEnum): void; |
@@ -1,2 +0,2 @@ | ||
import moment from "moment/moment"; | ||
import dayjs from "dayjs"; | ||
const UNIX_TIME_SEC_NULL_VALUE = 63072000; | ||
@@ -6,6 +6,6 @@ const UNIX_TIME_MS_NULL_VALUE = 63072000000; | ||
function unixTimeSecToMoment(value) { | ||
return moment.unix(value); | ||
return dayjs.unix(value); | ||
} | ||
function unixTimeMsToMoment(value) { | ||
return moment(value); | ||
return dayjs(value); | ||
} | ||
@@ -12,0 +12,0 @@ export let unixTimeToMoment = unixTimeSecToMoment; |
@@ -1,15 +0,15 @@ | ||
import moment, { Moment } from "moment"; | ||
import { Dayjs } from "dayjs"; | ||
import { UnixTime } from "d2core/types/unixTime"; | ||
import { TimeInterval } from "d2core/types/timeInterval"; | ||
export declare class DateTimeUtils { | ||
static timePeriodAsMoment(timePeriod: [Date | undefined, Date | undefined]): [moment.Moment | null, moment.Moment | null]; | ||
static timePeriodAsDate(timePeriod: [moment.Moment | null, moment.Moment | null]): [Date | undefined, Date | undefined]; | ||
static timePeriodAsUnixTime(timePeriod: [moment.Moment | null, moment.Moment | null]): [UnixTime | undefined, UnixTime | undefined]; | ||
static timePeriodAsMoment(timePeriod: [Date | undefined, Date | undefined]): [Dayjs | null, Dayjs | null]; | ||
static timePeriodAsDate(timePeriod: [Dayjs | null, Dayjs | null]): [Date | undefined, Date | undefined]; | ||
static timePeriodAsUnixTime(timePeriod: [Dayjs | null, Dayjs | null]): [UnixTime | undefined, UnixTime | undefined]; | ||
static timePeriodUnixTimeAsDate(timePeriod: undefined[] | [UnixTime] | [undefined, UnixTime] | [UnixTime | undefined, UnixTime | undefined]): [Date | undefined, Date | undefined]; | ||
static toUnixTime(date: moment.Moment | null): UnixTime; | ||
static fromUnixTime(unixTime: UnixTime): moment.Moment; | ||
static toUnixTime(date: Dayjs | null): UnixTime; | ||
static fromUnixTime(unixTime: UnixTime): Dayjs; | ||
static getMillisecondsFromDatePickerInputChange(dateFormat: string): number | undefined; | ||
static getRanges(timeIntervals: TimeInterval[]): { | ||
[rangeName: string]: () => [Moment, Moment]; | ||
[rangeName: string]: () => [Dayjs, Dayjs]; | ||
}; | ||
} |
@@ -1,2 +0,2 @@ | ||
import moment from "moment"; | ||
import dayjs from "dayjs"; | ||
import i18n from "d2core/i18n/i18n"; | ||
@@ -7,6 +7,6 @@ export class DateTimeUtils { | ||
if (timePeriod[1]) { | ||
return [moment(timePeriod[0]), moment(timePeriod[1])]; | ||
return [dayjs(timePeriod[0]), dayjs(timePeriod[1])]; | ||
} | ||
else { | ||
return [moment(timePeriod[0]), null]; | ||
return [dayjs(timePeriod[0]), null]; | ||
} | ||
@@ -16,3 +16,3 @@ } | ||
if (timePeriod[1]) { | ||
return [null, moment(timePeriod[0])]; | ||
return [null, dayjs(timePeriod[0])]; | ||
} | ||
@@ -38,3 +38,3 @@ else { | ||
static fromUnixTime(unixTime) { | ||
return moment(unixTime * 1000); | ||
return dayjs(unixTime * 1000); | ||
} | ||
@@ -45,5 +45,5 @@ static getMillisecondsFromDatePickerInputChange(dateFormat) { | ||
const stringValue = (_b = (_a = window.event) === null || _a === void 0 ? void 0 : _a.target) === null || _b === void 0 ? void 0 : _b.value; | ||
const parsedDate = moment(stringValue, dateFormat); | ||
const parsedDate = dayjs(stringValue, dateFormat); | ||
if (parsedDate.isValid()) { | ||
return parsedDate.milliseconds(); | ||
return parsedDate.millisecond(); | ||
} | ||
@@ -50,0 +50,0 @@ } |
export default class TimeUtils { | ||
static sleep(ms: number): Promise<unknown>; | ||
} |
@@ -0,0 +0,0 @@ export default class TimeUtils { |
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
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
158340
44.25%1
-50%47
56.67%1608
71.25%0
-100%2
100%+ Added
- Removed
- Removed
- Removed
- Removed