From af206ebbd7dae8bb59741b3ced7ac125a8fd91ff Mon Sep 17 00:00:00 2001 From: Safwan Samsudeen Date: Wed, 11 Sep 2024 20:51:53 +0530 Subject: [PATCH] fix: changes from #397 --- src/date_utils.js | 19 ++++--------------- src/index.js | 2 +- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/date_utils.js b/src/date_utils.js index 4d2e4f0..4698088 100644 --- a/src/date_utils.js +++ b/src/date_utils.js @@ -6,20 +6,6 @@ const MINUTE = 'minute'; const SECOND = 'second'; const MILLISECOND = 'millisecond'; -const SHORTENED = { - January: 'Jan', - February: 'Feb', - March: 'Mar', - April: 'Apr', - May: 'May', - June: 'Jun', - July: 'Jul', - August: 'Aug', - September: 'Sep', - October: 'Oct', - November: 'Nov', - December: 'Dec', -}; export default { parse_duration(duration) { @@ -97,6 +83,9 @@ export default { const dateTimeFormat = new Intl.DateTimeFormat(lang, { month: 'long', }); + const dateTimeFormatShort = new Intl.DateTimeFormat(lang, { + month: "short", + }); const month_name = dateTimeFormat.format(date); const month_name_capitalized = month_name.charAt(0).toUpperCase() + month_name.slice(1); @@ -112,7 +101,7 @@ export default { SSS: values[6], D: values[2], MMMM: month_name_capitalized, - MMM: SHORTENED[month_name_capitalized], + MMM: dateTimeFormatShort.format(date), }; let str = format_string; diff --git a/src/index.js b/src/index.js index a94e8cc..94973fc 100644 --- a/src/index.js +++ b/src/index.js @@ -867,7 +867,7 @@ export default class Gantt { formatted_date: date_utils.format(date).replaceAll(' ', '_'), column_width, base_pos_x: base_pos.x, - upper_text: this.options.lower_text + upper_text: this.options.upper_text ? this.options.upper_text( date, this.options.view_mode,