mirror of https://github.com/abpframework/abp.git
Browse Source
Introduces TimepickerI18nAdapter to provide localized AM/PM labels for NgbTimepickerI18n. Updates providers and index exports to register and expose the new adapter.pull/24194/head
3 changed files with 31 additions and 2 deletions
@ -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