UNPKG

6.29 kBTypeScriptView Raw
1import { TranslationWidth } from '@angular/common';
2export declare const enum NbDayPeriod {
3 AM = "AM",// before midday, 0 - 11 in 24-hour format.
4 PM = "PM"
5}
6export declare abstract class NbDateService<D> {
7 readonly DAYS_IN_WEEK: number;
8 /**
9 * Number of hours in AM/PM day periods.
10 **/
11 readonly HOURS_IN_DAY_PERIOD = 12;
12 protected locale: string;
13 setLocale(locale: any): void;
14 /**
15 * Checks if the date is between the start date and the end date.
16 * */
17 isBetween(date: D, start: D, end: D): boolean;
18 /**
19 * Checks is two dates have the same day.
20 * */
21 isSameDaySafe(date1: D, date2: D): boolean;
22 /**
23 * Checks is two dates have the same month.
24 * */
25 isSameMonthSafe(date1: D, date2: D): boolean;
26 /**
27 * Checks is two dates have the same year.
28 * */
29 isSameYearSafe(date1: D, date2: D): boolean;
30 /**
31 * Returns date with selected hour
32 * */
33 abstract setHours(date: D, hour: number): D;
34 /**
35 * Returns date with selected minute
36 * */
37 abstract setMinutes(date: D, minute: number): D;
38 /**
39 * Returns date with selected second
40 * */
41 abstract setSeconds(date: D, second: number): D;
42 /**
43 * Returns date with selected milliseconds
44 * */
45 abstract setMilliseconds(date: D, second: number): D;
46 /**
47 * Returns true if date string is valid date string according to the provided format.
48 * */
49 abstract isValidDateString(date: string, format: string): boolean;
50 /**
51 * Returns true if time string is valid time string according to the provided format.
52 * */
53 abstract isValidTimeString(date: string, format: string): boolean;
54 /**
55 * Returns today date.
56 * */
57 abstract today(): D;
58 /**
59 * Gets the time format based on locale
60 * */
61 abstract getLocaleTimeFormat(): string;
62 /**
63 * Gets the date of the month component of the given date.
64 */
65 abstract getDate(date: D): number;
66 /**
67 * Gets the hour component of the given date.
68 */
69 abstract getHours(date: D): number;
70 /**
71 * Gets the minute component of the given date.
72 */
73 abstract getMinutes(date: D): number;
74 /**
75 * Gets the second component of the given date.
76 */
77 abstract getSeconds(date: D): number;
78 /**
79 * Gets the second component of the given date.
80 */
81 abstract getMilliseconds(date: D): number;
82 /**
83 * Gets the month component of the given date.
84 * */
85 abstract getMonth(date: D): number;
86 /**
87 * Gets the year component of the given date.
88 * */
89 abstract getYear(date: D): number;
90 /**
91 * Returns day of the week of the given date.
92 */
93 abstract getDayOfWeek(date: D): number;
94 /**
95 * Returns first day of the week, it can be 1 if week starts from monday
96 * and 0 if from sunday and so on.
97 * */
98 abstract getFirstDayOfWeek(): number;
99 /**
100 * Returns localized month name by date and style.
101 * */
102 abstract getMonthName(date: D, style?: TranslationWidth): string;
103 /**
104 * Returns localized month name by month index and style.
105 * */
106 abstract getMonthNameByIndex(month: number, style?: TranslationWidth): string;
107 /**
108 * Returns localized days names.
109 * */
110 abstract getDayOfWeekNames(style?: TranslationWidth): string[];
111 /**
112 * Parses the date string according to the passed format.
113 * */
114 abstract parse(date: string, format: string): D;
115 /**
116 * Transforms the date to the string according to the passed format.
117 * */
118 abstract format(date: D, format: string): string;
119 /**
120 * Creates new date from year, month and date.
121 * */
122 abstract createDate(year: number, month: number, date: number): D;
123 /**
124 * Checks is two dates have the same year.
125 * */
126 abstract isSameYear(date1: D, date2: D): boolean;
127 /**
128 * Checks is two dates have the same month.
129 * */
130 abstract isSameMonth(date1: D, date2: D): boolean;
131 /**
132 * Checks is two dates have the same day.
133 * */
134 abstract isSameDay(date1: D, date2: D): boolean;
135 /**
136 * Compares two dates.
137 * Returns 0 if dates are the same.
138 * Returns 1 if the first date is greater than the second.
139 * Returns -1 if the second date is greater than the first.
140 * */
141 abstract compareDates(date1: D, date2: D): number;
142 /**
143 * Clones passed date.
144 * */
145 abstract clone(date: D): D;
146 /**
147 * Creates the same date but with day equals to 1.
148 * */
149 abstract getMonthStart(date: D): D;
150 /**
151 * Creates the same date but with day equals to the last day in this month.
152 * */
153 abstract getMonthEnd(date: D): D;
154 /**
155 * Creates the same date but with month equals to 0 and day equals to 1.
156 * */
157 abstract getYearStart(date: D): D;
158 /**
159 * Creates the same date but with month equals to 11 and day equals to 31.
160 * */
161 abstract getYearEnd(date: D): D;
162 /**
163 * Returns number of days in the date.
164 * */
165 abstract getNumberOfDaysInMonth(date: D): number;
166 /**
167 * Returns date with added number of days.
168 * */
169 abstract addDay(date: D, days: number): D;
170 /**
171 * Returns date with added number of months.
172 * */
173 abstract addMonth(date: D, months: number): D;
174 /**
175 * Returns date with added number of hours.
176 * */
177 abstract addHours(date: D, hour: number): D;
178 /**
179 * Returns date with added number of minutes.
180 * */
181 abstract addMinutes(date: D, minute: number): D;
182 /**
183 * Returns date with added number of years.
184 * */
185 abstract addYear(date: D, years: number): D;
186 abstract getId(): string;
187 abstract getWeekNumber(date: D): number;
188 abstract getDateFormat(): string;
189 abstract getTwelveHoursFormat(): string;
190 /**
191 * Returns date with added number of years.
192 * */
193 abstract valueOf(date: D): number;
194 isSameHourAndMinute(date1: D, date2: D): boolean;
195 isSameHour(date1: D, date2: D): boolean;
196 isSameMinute(date1: D, date2: D): boolean;
197 getTwentyFourHoursFormat(): string;
198 getTwentyFourHoursFormatWithSeconds(): string;
199 getTwelveHoursFormatWithSeconds(): string;
200 getDayPeriod(date: D): NbDayPeriod;
201}