@@ -2,7 +2,7 @@ import { Component, EventEmitter, forwardRef, Input, OnDestroy, Output } from '@
22import { ControlValueAccessor , NG_VALUE_ACCESSOR } from '@angular/forms' ;
33import { div_rd , max , min } from '@tubular/math' ;
44import { CalendarType , DateTime , defaultLocale , getStartOfWeek , GregorianChange , Timezone , YMDDate } from '@tubular/time' ;
5- import { clone , isEqual , isObject , isString , noop , toBoolean , toNumber } from '@tubular/util' ;
5+ import { clone , convertDigits , convertDigitsToAscii , isEqual , isObject , isString , noop , toBoolean , toNumber } from '@tubular/util' ;
66import { Subscription , timer } from 'rxjs' ;
77import { SafeHtml } from '@angular/platform-browser' ;
88
@@ -32,21 +32,22 @@ const multiplier = [0, 1, 1, 10, 100, 1000];
3232 providers : [ { provide : NG_VALUE_ACCESSOR , useExisting : forwardRef ( ( ) => CalendarPanelComponent ) , multi : true } ]
3333} )
3434export class CalendarPanelComponent implements ControlValueAccessor , OnDestroy {
35- private ymd : YMDDate = { y : 2021 , m : 1 , d : 1 } ;
36- private _gregorianChange : GregorianChange ;
37- private _showDst = false ;
38- private _minYear = 1 ;
39- private _maxYear = 9999 ;
40- private _firstDay = getStartOfWeek ( defaultLocale ) ;
4135 private baseValue = [ 0 , 0 , 0 ] ;
4236 private dateTime : DateTime = new DateTime ( ) ;
43- private onTouchedCallback : ( ) => void = noop ;
37+ private digitBase = '0' ;
38+ private _firstDay = getStartOfWeek ( defaultLocale ) ;
39+ private _gregorianChange : GregorianChange ;
40+ private _maxYear = 9999 ;
41+ private _minYear = 1 ;
4442 private onChangeCallback : ( _ : any ) => void = noop ;
45- private timerSubscription : Subscription ;
43+ private onTouchedCallback : ( ) => void = noop ;
4644 private pendingDelta = 0 ;
4745 private pendingEvent : MouseEvent = null ;
46+ private _showDst = false ;
47+ private timerSubscription : Subscription ;
4848 private _weekDayFormat = 'ddd' ;
4949 private _yearMonthFormat = 'MMM~Y~' ;
50+ private ymd : YMDDate = { y : 2021 , m : 1 , d : 1 } ;
5051
5152 @Input ( ) backgroundDecorator : DayDecorator ;
5253 calendar : CalendarDateInfo [ ] [ ] = [ ] ;
@@ -64,6 +65,9 @@ export class CalendarPanelComponent implements ControlValueAccessor, OnDestroy {
6465
6566 constructor ( ) {
6667 this . updateDayHeadings ( ) ;
68+ const base : string [ ] = [ ] ;
69+ convertDigitsToAscii ( this . dateTime . format ( 'D' ) , base ) ;
70+ this . digitBase = base [ 0 ] ;
6771 }
6872
6973 ngOnDestroy ( ) : void {
@@ -106,6 +110,9 @@ export class CalendarPanelComponent implements ControlValueAccessor, OnDestroy {
106110 @Input ( ) set locale ( value : string | string [ ] ) {
107111 if ( ! isEqual ( this . dateTime . locale , value ) ) {
108112 this . dateTime . locale = value ;
113+ const base : string [ ] = [ ] ;
114+ convertDigitsToAscii ( this . dateTime . format ( 'D' ) , base ) ;
115+ this . digitBase = base [ 0 ] ;
109116 this . updateCalendar ( ) ;
110117 }
111118 }
@@ -206,7 +213,7 @@ export class CalendarPanelComponent implements ControlValueAccessor, OnDestroy {
206213 const col = index % 7 ;
207214
208215 date . dayLength = dayLength ;
209- date . text = String ( date . d ) ;
216+ date . text = convertDigits ( String ( date . d ) , this . digitBase ) ;
210217 date . otherMonth = ( date . m !== month ) ;
211218 date . highlight = ( date . m === month && date . d === day ) ;
212219
@@ -362,7 +369,7 @@ export class CalendarPanelComponent implements ControlValueAccessor, OnDestroy {
362369 const maxx = ( div_rd ( this . _maxYear - 1 , multiplier [ mode ] ) + 1 ) * multiplier [ mode ] ;
363370
364371 if ( ( minn <= value && value <= maxx ) )
365- return min ( max ( value , this . _minYear ) , this . _maxYear ) . toString ( ) ;
372+ return convertDigits ( min ( max ( value , this . _minYear ) , this . _maxYear ) . toString ( ) , this . digitBase ) ;
366373 else
367374 return '' ;
368375 }
0 commit comments