@nextcloud/vue
Version:
Nextcloud vue components
43 lines (42 loc) • 1.46 kB
TypeScript
import { FormatDateOptions } from '@nextcloud/l10n';
import { MaybeRefOrGetter, 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;
}
/**
* 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>>;
export {};