UNPKG

@craftercms/studio-ui

Version:

Services, components, models & utils to build CrafterCMS authoring extensions.

63 lines (61 loc) 2.69 kB
/* * Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 3 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import { Moment } from 'moment-timezone'; import GlobalState from '../models/GlobalState'; export interface TimezoneDescriptor { name: string; offset: string; } export declare const getTimezones: () => TimezoneDescriptor[]; export declare function asDayMonthDateTime(date: string): string; export declare function asLocalizedDateTime( date: string | number | Date, localeCode: string, dateTimeFormatOptions?: GlobalState['uiConfig']['locale']['dateTimeFormatOptions'] ): string; export declare function getUserTimeZone(): string; export declare function getUserLocaleCode(): string; /** * Create ISO 8601 string **/ export declare const create8601String: (date: string, time: string, offset: string) => string; /** * Returns an array as ['yyyy-mm-dd', 'hh:mm:ss', '+/-nn:nn'] out of a ISO 8601 date string **/ export declare const get8601Pieces: (date: string | Date | number | Moment) => string[]; export declare function isSameDay(date1: Date, date2: Date): boolean; /** * Returns the Z offset (e.g. +01:00) from the offset number that represents the difference, * in minutes, between this date as evaluated in the UTC time zone, and the same date as evaluated * in the local time zone **/ export declare function getFormattedGmtOffsetFromTimezoneOffset(timezoneOffset: number): string; /** * Returns true if the date object is a valid date, false otherwise **/ export declare function isValidDate(date: Date): boolean; /** * Returns the Z offset (e.g. +01:00) of a timezone name, considering daylight savings of the date. **/ export declare function getZDateOffset(date: Date | Moment, timezone: string): string; /** * Creates a Date object that's the same moment in time as the original date but expressed in the target timezone **/ export declare function createTransposedToTimezoneDate(date: Date | Moment, targetTimezone: string): Date; /** * Creates a date that's at least half hour from now. **/ export declare function createAtLeastHalfHourInFutureDate(): Date;