vue-functional-calendar icon indicating copy to clipboard operation
vue-functional-calendar copied to clipboard

Changing the format of selectedDate

Open Hjortur17 opened this issue 3 years ago • 2 comments

Hi, I'm having one issue with the date picker. I have two inputs for the pickup date and dropoff date and I'm trying to use DayJS to calculate the difference between the days.

Is it possible to get the selectedDate in the same format as currentDate?

dropOffDate:Object
     currentDate:Wed Sep 23 2020 16:07:38 GMT+0000 (Greenwich Mean Time)
     dateRange:Object
     multipleDateRange:Array[0]
     selectedDate:"26/9/2020"
     selectedDateTime:false
     selectedDates:Array[0]
     selectedDatesItem:""
     selectedHour:"00"
     selectedMinute:"00"

Because if I try to format the selectedDate, DayJS says it's an Invalid Date

dayjs(this.booking.dropOffDate.selectedDate);

Hjortur17 avatar Sep 23 '20 16:09 Hjortur17

Note, these are my calendar settings:

calendarConfigs: {
     dayNames: ['Mán', 'Þri', 'Mið', 'Fim', 'Fös', 'Lau', 'Sun'],
     monthNames: ["Janúar", "Febrúar", "Mars", "Apríl", "Maí", "Júní", "Júlí", "Ágúst", "September", "Október", "Nóvember", "Desember"],
     disabledDates: ['beforeToday', 'today'],
     isDatePicker: true,
     isModal: true,
},

Hjortur17 avatar Sep 23 '20 16:09 Hjortur17

I faced the same issue on Safari. When I try to format the date with moment library moment(object.selectedDate).format('MMMM Do YYYY, h:mm:ss a'); or new Date object - new Date(object.selectedDate) , the passed selectedDate is invalid.

The error message behind the invalid selected from moment is the following: link.

Apparently, the date format returned by the vue functional calendar library is not recognized by all browsers.

placideirandora avatar Aug 17 '22 09:08 placideirandora

Hello. Thanks for your feedback. Now I don't have time to deal with the calendar. Please create pull requests, I will appreciate it, it will be useful for the community.

ManukMinasyan avatar Nov 02 '22 12:11 ManukMinasyan