-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrelative-time.d.ts
More file actions
45 lines (37 loc) · 1.3 KB
/
Copy pathrelative-time.d.ts
File metadata and controls
45 lines (37 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Definitions by: Ben Grynhaus <https://github.com/bengry>
type DateInput = Date | string | number;
interface Settings {
/**
* @default browser locale
* @example 'es'
*/
locale?: string;
/**
* @default { numeric: 'auto' }
*/
options?: Intl.RelativeTimeFormatOptions;
}
declare class RelativeTime {
/**
* Creates a new RelativeTime instance with specified settings
* @param settings Configuration object for locale and formatting options
*/
constructor(settings?: Settings);
/**
* Returns a relative time string comparing two dates
* @param d1 The date to format (target date)
* @param d2 The reference date (defaults to current time)
* @returns Formatted relative time string (e.g., "2 days ago", "in 3 hours")
*/
from(d1: DateInput, d2?: DateInput): string;
/**
* Static method for convenience - creates instance per call
* @param d1 The date to format (target date)
* @param d2 The reference date (defaults to current time)
* @param locale Optional locale string (e.g., 'es', 'fr')
* @returns Formatted relative time string (e.g., "2 days ago", "in 3 hours")
*/
static from(d1: DateInput, d2?: DateInput, locale?: string): string;
}
export = RelativeTime;
export as namespace RelativeTime;