ManukMinasyan / vue-functional-calendar

Vue.js Functional Calendar | Component/Package
https://vue-functional-calendar.now.sh/
MIT License
468 stars 84 forks source link

Changing the format of selectedDate #111

Closed Hjortur17 closed 1 year ago

Hjortur17 commented 3 years ago

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 commented 3 years ago

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,
},
placideirandora commented 2 years ago

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.

ManukMinasyan commented 1 year ago

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.