@nextcloud/vue
Version:
Nextcloud vue components
57 lines (56 loc) • 3.02 kB
TypeScript
import { Ref } from 'vue';
interface FormatDateOptions {
/**
* 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';
}
type MaybeRef<T> = T | Ref<T>;
/**
* Composable for formatting time stamps using current users locale and language
*
* @param {Date | number | import('vue').Ref<Date> | import('vue').Ref<number>} timestamp Current timestamp
* @param {object} opts Optional options
* @param {Intl.DateTimeFormatOptions} opts.format The format used for displaying, or if relative time is used the format used for the title (optional)
* @param {boolean} opts.ignoreSeconds Ignore seconds when displaying the relative time and just show `a few seconds ago`
* @param {false | 'long' | 'short' | 'narrow'} opts.relativeTime Wether to display the timestamp as time from now (optional)
*/
export declare function useFormatDateTime(timestamp?: MaybeRef<Date | number>, opts?: MaybeRef<FormatDateOptions>): {
formattedTime: import('vue').ComputedRef<string>;
formattedFullTime: import('vue').ComputedRef<string>;
options: Ref<{
format: {
localeMatcher?: "best fit" | "lookup" | undefined | undefined;
weekday?: "long" | "short" | "narrow" | undefined | undefined;
era?: "long" | "short" | "narrow" | undefined | undefined;
year?: "numeric" | "2-digit" | undefined | undefined;
month?: "numeric" | "2-digit" | "long" | "short" | "narrow" | undefined | undefined;
day?: "numeric" | "2-digit" | undefined | undefined;
hour?: "numeric" | "2-digit" | undefined | undefined;
minute?: "numeric" | "2-digit" | undefined | undefined;
second?: "numeric" | "2-digit" | undefined | undefined;
timeZoneName?: "short" | "long" | "shortOffset" | "longOffset" | "shortGeneric" | "longGeneric" | undefined | undefined;
formatMatcher?: "best fit" | "basic" | undefined | undefined;
hour12?: boolean | undefined | undefined;
timeZone?: string | undefined | undefined;
calendar?: string | undefined | undefined;
dayPeriod?: "narrow" | "short" | "long" | undefined | undefined;
numberingSystem?: string | undefined | undefined;
dateStyle?: "full" | "long" | "medium" | "short" | undefined | undefined;
timeStyle?: "full" | "long" | "medium" | "short" | undefined | undefined;
hourCycle?: "h11" | "h12" | "h23" | "h24" | undefined | undefined;
fractionalSecondDigits?: 1 | 2 | 3 | undefined | undefined;
};
ignoreSeconds: boolean;
relativeTime: false | "long" | "short" | "narrow";
}>;
};
export {};