14
14
15
15
import type Nullable from './common/Nullable'
16
16
import type DeepPartial from './common/DeepPartial'
17
+ import type PickRequired from './common/PickRequired'
17
18
import type { KLineData , VisibleRangeData } from './common/Data'
18
19
import type VisibleRange from './common/VisibleRange'
19
20
import type Coordinate from './common/Coordinate'
@@ -24,7 +25,7 @@ import type BarSpace from './common/BarSpace'
24
25
import type Precision from './common/Precision'
25
26
import Action from './common/Action'
26
27
import { ActionType , type ActionCallback } from './common/Action'
27
- import { formatValue , formatTimestampToString , formatBigNumber , formatThousands , formatFoldDecimal } from './common/utils/format'
28
+ import { formatValue , formatTimestampByTemplate , formatBigNumber , formatThousands , formatFoldDecimal } from './common/utils/format'
28
29
import { getDefaultStyles , type TooltipFeatureStyle , type Styles , type TooltipLegend } from './common/Styles'
29
30
import { isArray , isString , isValid , isNumber , isBoolean , isFunction , merge } from './common/utils/typeChecks'
30
31
import { createId } from './common/utils/id'
@@ -36,7 +37,7 @@ import { type LoadDataCallback, type LoadDataParams, LoadDataType } from './comm
36
37
import type TimeWeightTick from './common/TimeWeightTick'
37
38
import { classifyTimeWeightTicks , createTimeWeightTickList } from './common/TimeWeightTick'
38
39
39
- import type { Options , CustomApi , ThousandsSeparator , DecimalFold } from './Options'
40
+ import type { Options , CustomApi , ThousandsSeparator , DecimalFold , FormatDateType , FormatDateParams , FormatBigNumber } from './Options'
40
41
41
42
import { IndicatorDataState , type IndicatorOverride , type IndicatorCreate , type IndicatorFilter , type Indicator } from './component/Indicator'
42
43
import type IndicatorImp from './component/Indicator'
@@ -52,7 +53,6 @@ import { getStyles as getExtensionStyles } from './extension/styles/index'
52
53
import { PaneIdConstants } from './pane/types'
53
54
54
55
import type Chart from './Chart'
55
- import type PickRequired from './common/PickRequired'
56
56
57
57
const BarSpaceLimitConstants = {
58
58
MIN : 1 ,
@@ -150,10 +150,23 @@ export default class StoreImp implements Store {
150
150
* Custom api
151
151
*/
152
152
private readonly _customApi = {
153
- formatDate : ( timestamp : number , format : string ) => formatTimestampToString ( this . _dateTimeFormat , timestamp , format ) ,
153
+ formatDate : ( {
154
+ dateTimeFormat,
155
+ timestamp,
156
+ template
157
+ } : FormatDateParams ) => formatTimestampByTemplate ( dateTimeFormat , timestamp , template ) ,
154
158
formatBigNumber
155
159
}
156
160
161
+ /**
162
+ * Inner custom api
163
+ * @description Internal use only
164
+ */
165
+ private readonly _innerCustomApi = {
166
+ formatDate : ( timestamp : number , template : string , type : FormatDateType ) => this . _customApi . formatDate ( { dateTimeFormat : this . _dateTimeFormat , timestamp, template, type } ) ,
167
+ formatBigNumber : this . _customApi . formatBigNumber
168
+ }
169
+
157
170
/**
158
171
* Locale
159
172
*/
@@ -397,6 +410,13 @@ export default class StoreImp implements Store {
397
410
398
411
getCustomApi ( ) : CustomApi { return this . _customApi }
399
412
413
+ getInnerCustomApi ( ) : {
414
+ formatDate : ( timestamp : number , template : string , type : FormatDateType ) => string
415
+ formatBigNumber : FormatBigNumber
416
+ } {
417
+ return this . _innerCustomApi
418
+ }
419
+
400
420
setLocale ( locale : string ) : void { this . _locale = locale }
401
421
402
422
getLocale ( ) : string { return this . _locale }
0 commit comments