@explorer-1/vue 0.2.81 → 0.2.82

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/utils/mixins.ts +23 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@explorer-1/vue",
3
- "version": "0.2.81",
3
+ "version": "0.2.82",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -293,20 +293,33 @@ export const mixinFormatSplitEventDates = (
293
293
  endDatetime?: string,
294
294
  compact?: boolean
295
295
  ): EventDateObject => {
296
- const startDateDayjs = dayjs(startDatetime)
296
+ const endDateDayjs = endDatetime ? dayjs(endDatetime) : undefined
297
297
 
298
- const monthFormat = compact ? 'MM' : 'MMM'
299
- let day = startDateDayjs.format('D')
300
- const month = startDateDayjs.format(monthFormat).replace('.', '')
301
- const year = startDateDayjs.format('YYYY')
302
- const monthAndYear = startDateDayjs.format(`${monthFormat} YYYY`)
298
+ const startDateDayjs = () => {
299
+ // use the end date if the event has started but hasn't ended
300
+ let date = startDatetime
301
+ const startDate = startDatetime ? dayjs(startDatetime) : undefined
302
+ if (startDatetime && endDatetime && endDateDayjs && startDate) {
303
+ let now = dayjs(new Date())
304
+ if (endDateDayjs > now && startDate < now) {
305
+ date = endDatetime
306
+ } else {
307
+ date = startDatetime
308
+ }
309
+ }
310
+ return dayjs(date)
311
+ }
303
312
 
304
- if (endDatetime) {
305
- const endDateDayjs = dayjs(endDatetime)
313
+ const monthFormat = compact ? 'MM' : 'MMM'
314
+ let day = startDateDayjs().format('D')
315
+ const month = startDateDayjs().format(monthFormat).replace('.', '')
316
+ const year = startDateDayjs().format('YYYY')
317
+ const monthAndYear = startDateDayjs().format(`${monthFormat} YYYY`)
306
318
 
319
+ if (endDateDayjs) {
307
320
  if (
308
- startDateDayjs.format('MM') === endDateDayjs.format('MM') &&
309
- startDateDayjs.format('ll') !== endDateDayjs.format('ll')
321
+ startDateDayjs().format('MM') === endDateDayjs.format('MM') &&
322
+ startDateDayjs().format('ll') !== endDateDayjs.format('ll')
310
323
  ) {
311
324
  // If event spans multiple days within the same month, show both days
312
325
  day = `${day}-${endDateDayjs.format('D')}`