mirror of https://github.com/abpframework/abp.git
committed by
GitHub
5 changed files with 78 additions and 14 deletions
@ -0,0 +1,38 @@ |
|||
import { formatDate } from '@angular/common'; |
|||
import { inject, Injectable, LOCALE_ID } from '@angular/core'; |
|||
import { NgbDatepickerI18n, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap'; |
|||
import { ConfigStateService } from '@abp/ng.core'; |
|||
|
|||
@Injectable() |
|||
export class DatepickerI18nAdapter extends NgbDatepickerI18n { |
|||
private configState = inject(ConfigStateService, { optional: true }); |
|||
private defaultLocale = inject(LOCALE_ID); |
|||
|
|||
private get locale(): string { |
|||
return this.configState?.getDeep('localization.currentCulture.cultureName') || this.defaultLocale; |
|||
} |
|||
|
|||
getWeekdayLabel(weekday: number): string { |
|||
const date = new Date(2017, 0, weekday + 1); // Monday = 1
|
|||
return formatDate(date, 'EEEEE', this.locale); |
|||
} |
|||
|
|||
getWeekLabel(): string { |
|||
return ''; |
|||
} |
|||
|
|||
getMonthShortName(month: number): string { |
|||
const date = new Date(2017, month - 1, 1); |
|||
return formatDate(date, 'MMM', this.locale); |
|||
} |
|||
|
|||
getMonthFullName(month: number): string { |
|||
const date = new Date(2017, month - 1, 1); |
|||
return formatDate(date, 'MMMM', this.locale); |
|||
} |
|||
|
|||
getDayAriaLabel(date: NgbDateStruct): string { |
|||
const d = new Date(date.year, date.month - 1, date.day); |
|||
return formatDate(d, 'fullDate', this.locale); |
|||
} |
|||
} |
|||
@ -1,3 +1,5 @@ |
|||
export * from './date-time.adapter'; |
|||
export * from './date.adapter'; |
|||
export * from './datepicker-i18n.adapter'; |
|||
export * from './time.adapter'; |
|||
export * from './timepicker-i18n.adapter'; |
|||
|
|||
@ -0,0 +1,24 @@ |
|||
import { formatDate } from '@angular/common'; |
|||
import { inject, Injectable, LOCALE_ID } from '@angular/core'; |
|||
import { NgbTimepickerI18n } from '@ng-bootstrap/ng-bootstrap'; |
|||
import { ConfigStateService } from '@abp/ng.core'; |
|||
|
|||
@Injectable() |
|||
export class TimepickerI18nAdapter extends NgbTimepickerI18n { |
|||
private configState = inject(ConfigStateService, { optional: true }); |
|||
private defaultLocale = inject(LOCALE_ID); |
|||
|
|||
private get locale(): string { |
|||
return this.configState?.getDeep('localization.currentCulture.cultureName') || this.defaultLocale; |
|||
} |
|||
|
|||
getMorningPeriod(): string { |
|||
const date = new Date(2000, 0, 1, 10, 0, 0); |
|||
return formatDate(date, 'a', this.locale); |
|||
} |
|||
|
|||
getAfternoonPeriod(): string { |
|||
const date = new Date(2000, 0, 1, 22, 0, 0); |
|||
return formatDate(date, 'a', this.locale); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue