Daypilot C# Get Selected Day - javascript

I am building a master rota using Daypilot. I only care about Monday -Sunday. I don't care about DATES, just DAYS. E.G a shift created on a Monday between 2-4 will be there every Monday between 2-4.
I am using the TimeRangeSelectedJavaScript to call the modal popup
Is there a way using this javascript to get the selected DAY.
E.G if they try and create a appointment on the weekly calender on a Monday, then "Monday" can be passed through?
TimeRangeSelectedHandling="JavaScript"
TimeRangeSelectedJavaScript="timeRangeSelected(start, end,$('#MainContent_DropDownList_Week').val(), $('#MainContent_DropDownListLocationMasterRota').val());"

You can get the day of week from the start/end variables:
var startDow = start.getDayOfWeek();
var endDow = end.getDayOfWeek();
Both start and end variables hold a DayPilot.Date object. See also DayPilot.Date.getDayOfWeek().
Your example modified:
TimeRangeSelectedHandling="JavaScript"
TimeRangeSelectedJavaScript="timeRangeSelected(start.getDayOfWeek(), end.getDayOfWeek(), $('#MainContent_DropDownList_Week').val(), $('#MainContent_DropDownListLocationMasterRota').val());"

Related

Returning to calendar in month view always goes back one month,

I'm having difficulty getting my users to return to the month they were working in after a change is made.
Currently, I have a function that initializes the calendar.
var iv = localStorage.getItem("fcDefaultView") || 'timeGridWeek';
var id = localStorage.getItem("fcDefaultDate") || new Date;
initialView: iv,
initialDate: id,
datesSet: function (dateInfo) {
localStorage.setItem("fcDefaultView", dateInfo.view.type);
localStorage.setItem("fcDefaultDate", dateInfo.startStr);
},
What is strange is that, when the user is in any view other than monthView, everything works fine. But when in monthView, when they return to the calendar, it displays the previous month.
The issue you've got with the month view is that the "start" date of any month view in fullCalendar is often a day or two before the start of the month. For example if you open fullCalendar month view for the current month (August 2021) you'll see that the first date displayed on the calendar is 27th July. So if you log dateInfo.startStr as you're adding it to the localStorage, you'll see that for August 2021 (again for example) it'll save 27th July 2021.
However if you then set that as the initial date next time you load the calendar, fullCalendar then sets the view to the month which the date occurs in.
To solve this, rather than using the date provided directly in the datesSet callback, you can get the "currentStart" value from the view object, which is the start of the interval the view is trying to represent, rather than the start of the visible time period. This distinction only really applies in month view, so it has no impact on the already-working behaviour other views.
Change the setItem call to this:
localStorage.setItem("fcDefaultDate", dateInfo.view.currentStart);
As this is a JS Date object which then gets serialised, rather than an ISO string, you need to explicitly parse it when reading it out again, so another small change is required:
var id = Date.parse(localStorage.getItem("fcDefaultDate")) || new Date();
Demo: https://codepen.io/ADyson82/pen/JjNrMBd
Documentation: https://fullcalendar.io/docs/view-object
It's because the month starts from 0, not 1. so January is "0" and February is "1".

Time series in panda

How do I convert a date index into Time-based indexing?
so that i can later generate a month, weekday and a year
I tried this code
df['TRANS_DATE'] = pd.to_datetime(df['TRANS_DATE'], format='%m/%d/%Y %H:%M:%S')
but after I change it to Index the date revert back to show as object
What happens if you leave out the format option (letting it run to Default)? Also, it would be best if you show your original data.
Additional information -
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_datetime.html

How to make bootstrap datepicker pick last day of the month instead of first day when minViewMode : 1

I'm using this version of Bootstrap DatePicker: http://eternicode.github.io/bootstrap-datepicker/ (the range type), and i have uploaded my demo on JSFiddle on here: http://jsfiddle.net/qs5co179/6/
The relevant JavaScript:
$('#sandbox-container .input-daterange').datepicker({
format: "dd/mm/yyyy",
minViewMode : 1
});
I have set the parameter minViewMode : 1 so I can view only months on calendar instead of full days, the reason is that I want to strict the user to enter:
1st day of the month in: input name="start"
and strict them too to enter only the last day of the month in: input name="end" (but the default is always 1st day of the month when you click)
For example my data entry that i am looking for like below:
From: 01/07/2015 - To: 30/09/2015.. in this format (dd/mm/yyyy)
Now I can't find any parameter to set the calender to pick the last day of the month instead of always 1st day when you click on the month in "To:" field.
one more thing also that I want to always make "From:" and "To:" having 3months period and no less, I want always to make the range 3 months minimum for the entery.
Thanks a lot in advance...
You could attach an event handler to the changeDate event (doc), and change the date manually (i.e. add a month, substract a day).
For the date handling part, I would
Get the date parts
Increase the month by one, if its December, then change it to January
Create a new Date instance
date = date.setDate(date.getDate() - 1) to get the correct day
The date parts could be exctracted by simple string slicing:
var day = str.slice(0,2);
var month = str.slice(3,5);
var year = str.slice(6,10);

jQuery Datepicker previous complete months

I'm using the Datepicker in two input fields to allow users to select a start and end date, respectively. I was curious if there's a setting for jQuery UI's datepicker to initialize the start date field to a period that is two complete months prior to the end date, which defaults to the current date. So when a user opens the page, the end date will be the current date and the start date will display the two complete months prior to the current date, e.g. end date is initialized to 4-3-2012, the start date would be 2-1-12.
I was going to write some custom formula to handle this, but wanted to be sure there wasn't already a setting for this built into the Datepicker.
$( ".selector" ).datepicker({"defaultDate": ((today.getMonth() +11)%12) + "/01/" + today.getFullYear()});​
In order to "subtract 2" from the month, we add 11 and take the remainder because JS months are 0 based and we don't want to end up at -1 month.
edit: algorithm edited as per clarification
JsFiddle

how can you figure out the week from a single date

I am building a project and in that project the user is going to input a date eg. 8/2/2011. then i am going to show them the information for the week that contains 8/2/2011. How can you figure out which week to show? for this project i am using javascript, jquery, and php.
You should be able to do what you want by getting the first day of the week the given date occurs in.
If your weeks start on Monday:
Date.prototype.lastMonday=function(){
var d= new Date(this), weekstart= 1;
while(d.getDay()!== 1) d.setDate(d.getDate()-1)
return d;
}
alert(new Date().lastMonday())
//returns the current date if does fall on a Monday
If you want to know the days that compose the week you can just find out the day of the week and show the appropriate days before and after. To know the day of the week just use the getDay method of the Date object(see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/getDay). For more info on the Date object see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date.

Categories

Resources