UNPKG

@nextcloud/vue

Version:
76 lines (75 loc) 2.78 kB
import { FormatDateOptions } from '@nextcloud/l10n'; import { MaybeRefOrGetter } from '@vueuse/core'; import { Ref } from 'vue'; interface FormatRelativeTimeOptions extends Partial<Omit<FormatDateOptions, 'ignoreSeconds'>> { ignoreSeconds?: boolean; /** * If set to false the relative time will not be updated anymore. * * @default true - Meaning the relative time will be updated if needed */ update?: boolean; } interface FormatTimeOptions { /** * Locale to use for formatting. * * @default current locale */ locale?: string; /** * The format used for displaying. * * @default { timeStyle: 'medium', dateStyle: 'short' } */ format?: Intl.DateTimeFormatOptions; } /** * @deprecated */ interface LegacyFormatDateTimeOptions { /** * The format used for displaying, or if relative time is used the format used for the title */ format?: Intl.DateTimeFormatOptions; /** * Ignore seconds when displaying the relative time and just show `a few seconds ago` */ ignoreSeconds?: boolean; /** * Wether to display the timestamp as time from now */ relativeTime?: false | 'long' | 'short' | 'narrow'; } /** * Format a timestamp or date object as relative time. * * This is a composable wrapper around `formatRelativeTime` from `@nextcloud/l10n`. * * @param timestamp - The timestamp to format * @param opts - Formatting options */ export declare function useFormatRelativeTime(timestamp?: MaybeRefOrGetter<Date | number>, opts?: MaybeRefOrGetter<FormatRelativeTimeOptions>): Readonly<Ref<string>>; /** * Format a given timestamp or date object as a human readable string. * * @param timestamp - Timestamp or date object to format * @param opts - Formatting options */ export declare function useFormatTime(timestamp: MaybeRefOrGetter<number | Date>, opts: MaybeRefOrGetter<FormatTimeOptions>): Readonly<Ref<string>>; /** * Composable for formatting time stamps using current users locale and language * * @param timestamp Current timestamp * @param opts Optional options * @param opts.format The format used for displaying, or if relative time is used the format used for the title (optional) * @param opts.ignoreSeconds Ignore seconds when displaying the relative time and just show `a few seconds ago` * @param opts.relativeTime Wether to display the timestamp as time from now (optional) * * @deprecated use `useFormatRelativeTime` or `useFormatTime` instead. */ export declare function useFormatDateTime(timestamp?: MaybeRefOrGetter<Date | number>, opts?: MaybeRefOrGetter<LegacyFormatDateTimeOptions>): { formattedTime: import('vue').ComputedRef<string>; formattedFullTime: Readonly<Ref<string>>; }; export {};