I am using V-Date-Picker in vuetify. I am showing multiple dates in date picker. The shown dates were passed from application. But the date picker is showing wrong date format.
let date = new Date(), context = this.$store.state[this.parentName], date_array=[];
date= moment(date).format(context.defaultDateFormat);
let monthStart = moment(date).startOf('Month').format(context.defaultDateFormat);
date_array.push(monthStart);
date_array.push(date);
let format_date = [];
format_date.push(moment(monthStart).format('YYYY-MM-DD'));
format_date.push(moment(date).format('YYYY-MM-DD'));
this.$store.state[this.parentName].fields.filter(x => x.value == this.fieldName).find(x => x).date = format_date.toString();
this.$store.state[this.parentName].editedItem.Date = date_array.toString();
context.picker = format_date.toString();
Please help me out
Please check by using https://github.com/date-fns/date-fns for formatting the date
Install
npm i date-fns
Usage
import format from 'date-fns/format'
import parseISO from 'date-fns/parseISO'
your v-model variable=format(parseISO(date from variable),'yyyy-MM-dd')
Formatting options are available on https://date-fns.org
I'm using FullCalendar v4-alpha-3 with the RRule plugin to generate recurring events. It works as expected with only one problem: how do I modify a recurring event to account for months with fewer days than the starting month in a series?
For example, if the first monthly occurrence happens on January 29, 2019; the event will be repeated on the 29th of all subsequent months except in February since it only has 28 days (leap years excluded).
I've tried resetting dtstart to the first day of the following month. It works, except the event is no longer recursive.
Here's a stripped down snippet of my setup:
let calendar = new Calendar(calendarEl, {
plugins: [ rrulePlugin ],
events: [
{
rrule: 'DTSTART:20190129 RRULE:FREQ=MONTHLY;UNTIL=20200130;COUNT=13;BYMONTHDAY=29'
}
],
eventRender: function(info) {
...
// reset start date to the first day of the following month
// if current month has fewer days than base month
let start = event.start;
let day = start.getDate();
let now = new Date();
let currentMonth = now.getMonth();
let currentYear = now.getFullYear();
let daysInCurrent = getDaysInMonth(currentMonth + 1, currentYear);
let nextStart = start;
if (day > daysInCurrent) {
nextStart = new Date(currentYear, currentMonth + 1, 1);
event.setStart(nextStart);
event.setEnd(null);
}
}
});
I'd appreciate any insight.
Not quite the solution I hoped for, but RRule's bysetpos property seems to offer the next best alternative as it allows for a fallback date in case the one specified doesn't exist.
For example, the following would generate an occurrence on the 30th of every month; or the last day of the month if the 30th doesn’t exist:
FREQ=MONTHLY;BYMONTHDAY=28,29,30;BYSETPOS=-1.
Sourced from: https://icalevents.com/2555-paydays-last-working-days-and-why-bysetpos-is-useful/
I know this is an old question but maybe this will be usefull for someone:
I'm using momentjs library
monthly:
let endofmonth = moment('2020-02-29', "YYYY-MM-DD").endOf('month').format('DD');
let curday = moment('2020-02-29, "YYYY-MM-DD").format('DD');
single_event.title = title;
single_event.rrule = {};
single_event.rrule.freq = 'monthly';
single_event.rrule.dtstart = start_date;
single_event.rrule.interval = reminder_interval;
single_event.rrule.count = reminder_count;
if(endofmonth == curday){
// Checking if given day of the month is last
single_event.rrule.byweekday = ['mo','tu','we','th','fr','sa','su'];
single_event.rrule.bysetpos = -1;
}
else{
single_event.rrule.bymonthday = parseInt(curday);
}
calendar_events.push(single_event);
var calendar = new FullCalendar.Calendar(calendarEl, {
...
events: calendar_events
});
yearly:
single_event.title = title;
single_event.rrule = {};
single_event.rrule.dtstart = start_date;
single_event.rrule.count = parseInt(reminder_count);
if(endofmonth == curday){
// Checking if given day of the month is last
single_event.rrule.freq = 'monthly'; // Will work as yearly if interval is 12
single_event.rrule.interval = parseInt(reminder_interval)*12;
single_event.rrule.bymonthday = [28,29,30,31];
single_event.rrule.bysetpos = -1;
}
else{
single_event.rrule.freq = 'yearly';
single_event.rrule.bymonthday = parseInt(curday);
}
calendar_events.push(single_event);
var calendar = new FullCalendar.Calendar(calendarEl, {
...
events: calendar_events
});
I need to create a unit test for the following function:
export default date => {
const dateInMs = new Date(date).getTime(); // UTC date
const clientDate = new Date();
// timezone offset is in minutes therefore it is being converted to milliseconds
const offset = clientDate.getTimezoneOffset() * 60 * 1000;
return new Date(dateInMs - offset).toISOString();
};
I know I should pass the test a date in the following format
2017-07-01T00:00:00+00:00
Can someone provide some guidance as to how to write a simple test with this information.
Here is my Kendo datetime picker code
#(Html.Kendo().DateTimePicker()
.Name("start")
.Value(DateTime.Today)
.ParseFormats(new string[] { "MM/dd/yyyy" })
)
by this am getting 12/22/2014 12:00 AM but i want to diplay as 12/22/2014 00:00:00
how can i set default start date to the current day with the time set to 00:00:00
I tried like this but am not getting to display time as 00:00:00
var today = new Date();
var day = today.getDate();
var month = today.getMonth();
var year = today.getFullYear();
$('#FromDate').data('kendoDateTimePicker').value(month, day, year);
$('#FromDate').data('kendoDateTimePicker').value(new Date("MM/dd/yyyy"));
Thanks for the help
I believe that is what you want: http://dojo.telerik.com/UBaQe ?
So in the C# ASP.MVC this code should work:
#(Html.Kendo().DateTimePicker()
.Name("start")
.Value(DateTime.Today)
.ParseFormats(new string[] { "MM/dd/yyyy" })
.Format("yyyy/MM/dd HH:mm:ss")
.TimeFormat("HH:mm:ss")
)
How to get the no of days between two date picker controls in info path except sundays?
If It is possible let me know.
Thanks in advance.........
Using custom code you can do it easily. In this case I'm calculating the number of days (except Sundays) between a given date and today's date.
var navigator = this.MainDataSource.CreateNavigator();
string startDate = navigator.SelectSingleNode("/my:myFields/my:date_start", NamespaceManager).Value;
DateTime startDateTime = DateTime.ParseExact(startDate, "yyyy-MM-dd", null);
DateTime today = DateTime.Today;
int count = 0;
while (startDateTime > today)
{
today = today.AddDays(1);
if (today.DayOfWeek != DayOfWeek.Sunday)
{
count++;
}
}
I hope it helps