@icvdeveloper/common-module 0.0.111 → 0.0.113

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "v3plus-common-module",
3
3
  "configKey": "v3plusCommonModule",
4
- "version": "0.0.111"
4
+ "version": "0.0.113"
5
5
  }
@@ -21,10 +21,14 @@ export type UseConferenceHelpersMethods = {
21
21
  * Get conference webcast url
22
22
  */
23
23
  getConferenceWebcastUrl: (_conference?: Conference, _eventPath?: string) => string;
24
+ /**
25
+ * Get timezone display
26
+ */
27
+ getTimezoneDisplay: (sqlDate: string, timezone: string, showTwoCharTz: boolean) => string;
24
28
  /**
25
29
  * Get conference display date.
26
30
  */
27
- getConferenceDisplayDate: (_conference: Conference, showDate: boolean, showTime: boolean, showEndTime: boolean) => string;
31
+ getConferenceDisplayDate: (_conference: Conference, showDate: boolean, showTime: boolean, showEndTime: boolean, showTwoCharTz: boolean) => string;
28
32
  /**
29
33
  * Determine if show view archive button should be shown
30
34
  */
@@ -1,5 +1,5 @@
1
1
  import { toRefs } from "vue";
2
- import { format, parseISO } from "date-fns";
2
+ import { DateTime } from "luxon";
3
3
  import { get, find } from "lodash-es";
4
4
  import { storeToRefs } from "pinia";
5
5
  import { useRoute } from "vue-router";
@@ -74,60 +74,67 @@ export const useConferenceHelpers = (conference) => {
74
74
  const viewNowAliasText = globalConfigValue.value("view_now_button_alias");
75
75
  return viewNowAliasText || "View Now";
76
76
  };
77
- const getConferenceDisplayDate = (_conference, showDate = true, showTime = false, showEndTime = false) => {
77
+ const getTimezoneDisplay = (sqlDate, timezone, showTwoCharTz) => {
78
+ let tz = "";
79
+ if (pagesConfigValue.value("main.use_event_text_tz")) {
80
+ let threeCharTz = DateTime.fromSQL(
81
+ sqlDate,
82
+ { zone: timezone }
83
+ ).toLocal().offsetNameShort;
84
+ tz = threeCharTz;
85
+ if (showTwoCharTz) {
86
+ if (threeCharTz.length >= 3 && threeCharTz.length <= 4 && (threeCharTz.charAt(threeCharTz.length - 2) == "S" || threeCharTz.charAt(threeCharTz.length - 2) == "D")) {
87
+ let twoCharTz = threeCharTz.substring(0, threeCharTz.length - 2) + threeCharTz.charAt(threeCharTz.length - 1);
88
+ tz = twoCharTz;
89
+ }
90
+ }
91
+ }
92
+ return tz;
93
+ };
94
+ const getConferenceDisplayDate = (_conference, showDate = true, showTime = false, showEndTime = false, showTwoCharTz = false) => {
78
95
  const _selectedConference = _getSelectedConference(_conference);
79
96
  const startDate = _selectedConference.start_date;
80
97
  const endDate = _selectedConference.end_date;
81
98
  let returnDate = "";
82
- const tzFormat = pagesConfigValue.value("main.use_event_text_tz") ? " zzz" : "";
83
99
  if (isSingleDayEvent()) {
84
100
  const startFormat = "MMMM d, yyyy ";
85
101
  if (showDate) {
86
- returnDate += formatTimezoneToLocal(
102
+ returnDate += DateTime.fromSQL(
87
103
  startDate,
88
- startFormat,
89
- _selectedConference.timezone
90
- );
104
+ { zone: _selectedConference.timezone }
105
+ ).toLocal().toFormat(startFormat);
91
106
  }
92
107
  if (showTime) {
93
- returnDate += formatTimezoneToLocal(
108
+ returnDate += DateTime.fromSQL(
94
109
  startDate,
95
- "h:mm a",
96
- _selectedConference.timezone
97
- );
110
+ { zone: _selectedConference.timezone }
111
+ ).toLocal().toFormat("h:mm a");
98
112
  if (showEndTime) {
99
- returnDate += " - " + formatTimezoneToLocal(
113
+ returnDate += " - " + DateTime.fromSQL(
100
114
  endDate,
101
- "h:mm a",
102
- _selectedConference.timezone
103
- );
115
+ { zone: _selectedConference.timezone }
116
+ ).toLocal().toFormat("h:mm a");
104
117
  }
105
- returnDate += formatTimezoneToLocal(
106
- startDate,
107
- tzFormat,
108
- _selectedConference.timezone
109
- );
118
+ returnDate += " " + getTimezoneDisplay(startDate, _selectedConference.timezone, showTwoCharTz);
110
119
  }
111
120
  } else if (showDate) {
112
- let startFormat = "MMMM do";
113
- if (format(parseISO(startDate), "yyyy") !== format(parseISO(endDate), "yyyy")) {
121
+ let startFormat = "MMMM d";
122
+ if (DateTime.fromSQL(startDate).toFormat("yyyy") !== DateTime.fromSQL(endDate).toFormat("yyyy")) {
114
123
  startFormat += ", yyyy";
115
124
  }
116
- returnDate += formatTimezoneToLocal(
125
+ returnDate += DateTime.fromSQL(
117
126
  startDate,
118
- startFormat,
119
- _selectedConference.timezone
120
- );
121
- returnDate += " - ";
122
- let endFormat = "d, yyyy" + tzFormat;
123
- if (format(parseISO(startDate), "MMMM") !== format(parseISO(endDate), "MMMM") || format(parseISO(startDate), "yyyy") !== format(parseISO(endDate), "yyyy")) {
127
+ { zone: _selectedConference.timezone }
128
+ ).toLocal().toFormat(startFormat);
129
+ let endFormat = "d, yyyy";
130
+ if (DateTime.fromSQL(startDate).toFormat("MMMM") !== DateTime.fromSQL(endDate).toFormat("MMMM") || DateTime.fromSQL(startDate).toFormat("yyyy") !== DateTime.fromSQL(endDate).toFormat("yyyy")) {
124
131
  endFormat = "MMMM " + endFormat;
125
132
  }
126
- returnDate += formatTimezoneToLocal(
133
+ returnDate += " - " + DateTime.fromSQL(
127
134
  endDate,
128
- endFormat,
129
- _selectedConference.timezone
130
- );
135
+ { zone: _selectedConference.timezone }
136
+ ).toLocal().toFormat(endFormat);
137
+ returnDate += " " + getTimezoneDisplay(endDate, _selectedConference.timezone, showTwoCharTz);
131
138
  }
132
139
  return returnDate;
133
140
  };
@@ -254,6 +261,7 @@ export const useConferenceHelpers = (conference) => {
254
261
  showConferenceWebcastButton,
255
262
  getConferenceWebcastButtonText,
256
263
  getConferenceWebcastUrl,
264
+ getTimezoneDisplay,
257
265
  getConferenceDisplayDate,
258
266
  showViewArchiveButton,
259
267
  getViewArchiveUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icvdeveloper/common-module",
3
- "version": "0.0.111",
3
+ "version": "0.0.113",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {