mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
[javascript-time-ago] Fix types (#42269)
* Fix javascript-time-ago types * Enhanced types * Fix types * Fix files entries * Fix files entries * Fix files entries * Fix files entries * Fix files entries * Fix files entries * Fix files entries
This commit is contained in:
@@ -128,4 +128,4 @@ locale/gu/index.d.ts
|
||||
locale/ms/index.d.ts
|
||||
locale/ro/index.d.ts
|
||||
locale/ka/index.d.ts
|
||||
locale/ti/index.d.ts
|
||||
locale/ti/index.d.ts
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Gradation } from './';
|
||||
|
||||
declare const canonical: Gradation[];
|
||||
|
||||
export default canonical;
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Gradation } from './';
|
||||
|
||||
declare const convenient: Gradation[];
|
||||
|
||||
export default convenient;
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Gradation, Unit } from '.';
|
||||
|
||||
export const minute: number;
|
||||
export const hour: number;
|
||||
export const day: number;
|
||||
export const month: number;
|
||||
export const year: number;
|
||||
export function getStep(gradation: Gradation[], unit: Unit): Gradation | undefined;
|
||||
export function getDate(value: Date | number): Date;
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
export type Unit = 'now' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
|
||||
|
||||
export interface Gradation {
|
||||
unit?: Unit;
|
||||
factor?: number;
|
||||
granularity?: number;
|
||||
threshold?: number;
|
||||
threshold_for_now?: number;
|
||||
threshold_for_second?: number;
|
||||
threshold_for_minute?: number;
|
||||
threshold_for_hour?: number;
|
||||
threshold_for_day?: number;
|
||||
threshold_for_week?: number;
|
||||
threshold_for_month?: number;
|
||||
threshold_for_year?: number;
|
||||
}
|
||||
|
||||
export { default as canonical } from './canonical';
|
||||
export { default as convenient } from './convenient';
|
||||
export { minute, hour, day, month, year, getStep, getDate } from './helpers';
|
||||
Vendored
+11
-3
@@ -2,16 +2,24 @@
|
||||
// Project: https://github.com/catamphetamine/javascript-time-ago
|
||||
// Definitions by: Erik Burton <https://github.com/erikburt>
|
||||
// Henry Nguyen <https://github.com/HenryNguyen5>
|
||||
// Luis Felipe Zaguini <https://github.com/zaguiini>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { Locale, TimeUnit, Duration, DefaultFormats, RTFFormatter, Formats, QuantifyType } from "./locale";
|
||||
import {
|
||||
DefaultFormats,
|
||||
Duration,
|
||||
Formats,
|
||||
Locale,
|
||||
RTFFormatter,
|
||||
TimeUnit
|
||||
} from './locale';
|
||||
import { FormatStyle } from './style';
|
||||
|
||||
export = TimeAgo;
|
||||
|
||||
declare class TimeAgo {
|
||||
constructor(locales?: string | string[]);
|
||||
|
||||
format(input: Date | number, style?: string): string;
|
||||
format(input: Date | number, style?: string | FormatStyle): string;
|
||||
formatNumber(number: number): string;
|
||||
formatValue(value: Date | number, unit: TimeUnit, localeData: Duration): string;
|
||||
getFormatter(flavor: DefaultFormats): RTFFormatter;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import { FormatStyle } from './index';
|
||||
|
||||
export default FormatStyle;
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import { Gradation, Unit } from '../gradation';
|
||||
import { Locale } from '../locale';
|
||||
|
||||
export type Flavour = 'tiny' | 'short-time' | 'narrow' | 'short' | 'long';
|
||||
|
||||
export interface CustomFormatterOptions {
|
||||
now: number;
|
||||
date?: Date;
|
||||
time: number;
|
||||
elapsed: number;
|
||||
locale: Locale;
|
||||
}
|
||||
|
||||
export type CustomFormatter = (options: CustomFormatterOptions) => string | undefined;
|
||||
|
||||
export interface FormatStyle {
|
||||
units?: Unit;
|
||||
gradation?: Gradation[];
|
||||
flavour?: Flavour[];
|
||||
custom?: CustomFormatter;
|
||||
format?(date: Date | number, locale: Locale): string;
|
||||
}
|
||||
|
||||
export { default as timeStyle } from './time';
|
||||
export { default as twitterStyle } from './twitter';
|
||||
export { default as defaultStyle } from './default';
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { FormatStyle } from './index';
|
||||
|
||||
export default FormatStyle;
|
||||
@@ -0,0 +1,3 @@
|
||||
import { FormatStyle } from './index';
|
||||
|
||||
export default FormatStyle;
|
||||
Reference in New Issue
Block a user