11import dateLocalization from '@js/common/core/localization/date' ;
22import dateUtils from '@js/core/utils/date' ;
3+ import { getGlobalFormatByDataType } from '@ts/core/m_global_format_config' ;
34
45import type { TargetedAppointment , ViewType } from '../../types' ;
56
7+ const formatTooltipDatePart = ( date : Date ) : string => {
8+ const globalFormat = getGlobalFormatByDataType ( 'date' ) ;
9+
10+ if ( globalFormat ) {
11+ return dateLocalization . format ( date , globalFormat ) as string ;
12+ }
13+
14+ return String ( dateLocalization . format ( date , 'monthandday' ) ) ;
15+ } ;
16+
17+ const formatTooltipTimePart = ( date : Date ) : string => {
18+ const globalFormat = getGlobalFormatByDataType ( 'time' ) ;
19+
20+ if ( globalFormat ) {
21+ return dateLocalization . format ( date , globalFormat ) as string ;
22+ }
23+
24+ return String ( dateLocalization . format ( date , 'shorttime' ) ) ;
25+ } ;
26+
627export enum DateFormatType {
728 DATETIME = 'DATETIME' ,
829 TIME = 'TIME' ,
@@ -25,24 +46,22 @@ export const getDateFormatType = (
2546} ;
2647
2748export const getDateText = ( startDate : Date , endDate : Date , formatType : DateFormatType ) : string => {
28- const dateFormat = 'monthandday' ;
29- const timeFormat = 'shorttime' ;
3049 const isSameDate = dateUtils . sameDate ( startDate , endDate ) ;
3150
3251 switch ( formatType ) {
3352 case DateFormatType . DATETIME :
3453 return [
35- dateLocalization . format ( startDate , dateFormat ) ,
54+ formatTooltipDatePart ( startDate ) ,
3655 ' ' ,
37- dateLocalization . format ( startDate , timeFormat ) ,
56+ formatTooltipTimePart ( startDate ) ,
3857 ' - ' ,
39- isSameDate ? '' : `${ dateLocalization . format ( endDate , dateFormat ) } ` ,
40- dateLocalization . format ( endDate , timeFormat ) ,
58+ isSameDate ? '' : `${ formatTooltipDatePart ( endDate ) } ` ,
59+ formatTooltipTimePart ( endDate ) ,
4160 ] . join ( '' ) ;
4261 case DateFormatType . TIME :
43- return `${ dateLocalization . format ( startDate , timeFormat ) } - ${ dateLocalization . format ( endDate , timeFormat ) } ` ;
62+ return `${ formatTooltipTimePart ( startDate ) } - ${ formatTooltipTimePart ( endDate ) } ` ;
4463 case DateFormatType . DATE :
45- return `${ dateLocalization . format ( startDate , dateFormat ) } ${ isSameDate ? '' : ` - ${ dateLocalization . format ( endDate , dateFormat ) } ` } ` ;
64+ return `${ formatTooltipDatePart ( startDate ) } ${ isSameDate ? '' : ` - ${ formatTooltipDatePart ( endDate ) } ` } ` ;
4665 default :
4766 return '' ;
4867 }
0 commit comments