How to use EXDATE in Full Calendar via object option - vue.js

Looking at this answer, it is shown how to include EXDATE in the string format option in FullCalendar.
But FullCalendar provides a convenient alternative to the long string. They allow you to use an object instead. Unfortunately their documentation doesn't really cover anything beyond that:
The rrule property accepts whatever the rrule lib accepts for a new
RRule. See the docs. You can specify a string or an object.
The events we use are pretty heavy already and I would love to avoid adding additional complexity that would involve me writing some kind of mapper to generate this string.
I would like to know how to be able to exclude a list a of dates from a recurrence rule using the object format.
I've tried providing a date object of the specific date. I've tried providing an ISO string. I've tried including them in an array.
Update
This is the latest iteration that I'm trying:
...
const rruleSet = new RRuleSet();
rruleSet.rrule(new RRule(options));
// Repeat every day except on Nov 22, 2019
rruleSet.exdate(new Date(Date.UTC(2019, 10, 22)));
event.duration = {
seconds: event.event_length,
};
event.rrule = rruleSet.toString();
...
This renders the recurring dates (time is a little off) but the date that I'm trying to exclude still renders.

In order for your exclusion rule to match the generated event, you must include the specific time as well. I expect this is because if you had events repeating multiple times in the day it wouldn't know which one you were trying to exclude.
(If your events were "all-day" style events, without a specific start time, then setting just the date in exdate would be ok.)
Therefore, changing
rruleSet.exdate(new Date(Date.UTC(2019, 10, 22)));
to
rruleSet.exdate(new Date(Date.UTC(2019, 10, 22, 10, 30)));
will solve your problem
Demo: https://codepen.io/ADyson82/pen/jOORaOZ

Related

RangeTool update on event in bokeh

I'm trying to compute some statistics on a given range of data from a plot using a bokeh app. For selecting the range I am using RangeTool. However I cannot find the way to detect the event. I'm using as base this example:
https://docs.bokeh.org/en/latest/docs/gallery/range_tool.html
Then I tried:
def func():
print(range_rool._property_values['x_range'].start)
return
def func_e(event):
print('event detected')
return
range_rool.on_event(ButtonClick,func_e)
range_rool.on_event(Press,func)
range_rool.on_change("x_range",func)
but when I move the slider I don't see any difference. Any idea very welcome. Thanks
The RangeTool updates the range it is configured with, you can (and should) just add callbacks on the range itself, e.g.:
range_tool.x_range.on_change('start', ...)
Regarding the line range_rool.on_change("x_range",func) that you have, it's worth explaining that that instructs Bokeh to run func when the range object itself is wholesale replaced, i.e.
range_tool.x_range = some_new_Range1d
would trigger that callback. But the range is never normally replaced liked that. Instead, the start and end values of a single range are updated over time.
Also, as an aside, there is never any valid reason at all to access _properties. It is a private API and subject to change at any time.

jQuery Input Masks for datetime input using sql timestamp yyyy/mm/dd hh:mm:ss

I'm using Robin Herbot's jQuery Input Masks plugin on my project.
It's very good but I need sql timestamp mask: yyyy/mm/dd hh:mm:ss I don't konw if i'm doing something wrong but it seems datetime alias shows only hours and minutes.
I've tried some changes on mask but not successful.
Thanks.
I see the question is from long ago, I also came here while trying to learn jquery.inputmask.
Remember to always include what you have done (code sample) when asking a question. Even if it is wrong/not working, it will help the one providing an answer, and others looking for answers.
In general terms, I found it somewhat helpful to read through the jquery.inputmask.xxx.extensions.js files, where xxx = date in this instance. In there you can see how more complex aliases are constructed from more basic ones (by overriding the basic ones), and you can apply the same ideas in constructing a new alias if you don't find a useful one.
Code that should work for your case:
$("#tsfield").inputmask("timestamp", {
mask: "y/1/2 h:s:s",
placeholder: "yyyy/mm/dd hh:mm:ss",
separator: "/",
alias: "datetime",
hourFormat: "24"
});
... which creates a new alias named timestamp, overriding datetime, and applies it to the input with id="tsfield".
If you have more than one input field with the same input mask on your page, I find it is better to create the new alias just once in your $(document).ready(), and then apply it by name to each field (refer to jquery.inputmask.date.extensions.js and documentation for instructions).

Enter date into function without quotes, return date

I'm trying to write a function of this form:
Function cont(requestdate As Date)
cont = requestdate
End Function
Unfortunately, when I enter =cont(12/12/2012) into a cell, I do not get my date back. I get a very small number, which I think equals 12 divided by 12 divided by 2012. How can I get this to give me back the date? I do not want the user to have to enter =cont("12/12/2012").
I've attempted to google for an answer, unfortunately, I have not found anything helpful. Please let me know if my vocabulary is correct.
Let's say my user pulled a report with 3 columns, a, b and c. a has beginning of quarter balances, b has end of quarter balances and c has a first and last name. I want my user to put in column d: =cont(a1,b1,c1,12/12/2012) and make it create something like:
BOQ IS 1200, EOQ IS 1300, NAME IS EDDARD STARK, DATE IS 12/12/2012
So we could load this into a database. I apologize for the lack of info the first time around. To be honest, this function wouldn't save me a ton of time. I'm just trying to learn VBA, and thought this would be a good exercise... Then I got stuck.
Hard to tell what you are really trying to accomplish.
Function cont(requestdate As String) As String
cont = Format(Replace(requestdate, ".", "/"), "'mm_dd_YYYY")
End Function
This code will take a string that Excel does not recognize as a number e.g. 12.12.12 and formats it (about the only useful thing I can think of for this UDF) and return it as a string (that is not a number or date) to a cell that is formatted as text.
You can get as fancy as you like in processing the string entered and formatting the string returned - just that BOTH can never be a number or a date (or anything else Excel recognizes.)
There is no way to do exactly what you're trying to do. I will try to explain why.
You might think that because your function requires a Date argument, that this somehow forces or should force that 12/12/2012 to be treated as a Date. And it is treated as a Date — but only after it's evaluated (only if the evaluated expression cannot be interpreted as a Date, then you will get an error).
Why does Excel evaluate this before the function receives it?
Without requiring string qualifiers, how could the application possibly know what type of data you intended, or whether you intended for that to be evaluated? It could not possibly know, so there would be chaos.
Perhaps this is best illustrated by example. Using your function:
=Cont(1/1/0000) should raise an error.
Or consider a very simple formula:
=1/2
Should this formula return .5 (double) or January 2 (date) or should it return "1/2" (string literal)? Ultimately, it has to do one of these, and do that one thing consistently, and the one thing that Excel will do in this case is to evaluate the expression.
TL;DR
Your problem is that unqualified expression will be evaluated before being passed, and this is done to avoid confusion or ambiguity (per examples).
Here is my method for allowing quick date entry into a User Defined Function without wrapping the date in quotes:
Function cont(requestdate As Double) As Date
cont = CDate((Mid(Application.Caller.Formula, 7, 10)))
End Function
The UDF call lines up with the OP's initial request:
=cont(12/12/2012)
I believe that this method would adapt just fine for the OP's more complex ask, but suggest moving the date to the beginning of the call:
=cont(12/12/2012,a1,b1,c1)
I fully expect that this method can be optimized for both speed and flexibility. Working on a project now that might require me to further dig into the speed piece, but it suits my needs in the meantime. Will update if anything useful turns up.
Brief Explanation
Application.Caller returns a Range containing the cell that called the UDF. (See Caveat #2)
Mid returns part of a string (the formula from the range that called the UDF in this case) starting at the specified character count (7) of the specified length (10).
CDate may not actually be necessary, but forces the value into date format if possible.
Caveats
This does require use of the full dd/mm/yyyy (1/1/2012 would fail) but pleasantly still works with my preferred yyyy/mm/dd format as well as covering some other delimiters. dd-mm-yyyy or dd+mm+yyyy would work, but dd.mm.yyyy will not because excel does not recognize it as a valid number.
Additional work would be necessary for this to function as part of a multi-cell array formula because Application.Caller returns a range containing all of the associated cells in that case.
There is no error handling, and =cont(123) or =cont(derp) (basically anything not dd/mm/yyy) will naturally fail.
Disclaimers
A quick note to the folks who are questioning the wisdom of a UDF here: I've got a big grid of items and their associated tasks. With no arguments, my UDF calculates due dates based on a number of item and task parameters. When the optional date is included, the UDF returns a delta between the actual date and what was calculated. I use this delta to monitor and calibrate my calculated due dates.
All of this can absolutely be performed without the UDF, but bulk entry would be considerably more challenging to say the least.
Removing the need for quotes sets my data entry up such that loading =cont( into the clipboard allows my left hand to F2/ctrl-v/tab while my right hand furiously enters dates on the numpad without need to frequently (and awkwardly) shift left-hand position for a shift+'.

How to get work days and absence days of an employee (resource)?

How do I get the work and absence days of an employee with VBA from MS-Project? (an employee is a ressource)
Some additional infos:
I know how to get tasks
Dim ts as Tasks
Set ts = ActiveProject.Tasks
and I know how to get ressources from my project file:
Dim rs as Resources
Set rs = ActiveProject.ressources
but I do not find a (trivial) way to get work and absence days from this variables.
You need to look at the Resource object to find the working and non-working days:
ActiveProject.Resources.Item(1).Calendar
In this trivial example we're picking up the first resource in the project and pulling out it's associated Calendar.
A resource calendar will have a base calendar from which it inherits:
...Calendar.BaseCalendar
and both the resource calendar and the base calendar define working days, working weeks and exceptions. Exceptions are typically how periods of absence are defined... i.e. they are exceptions to the normal pattern of work:
...Calendar.WorkWeeks
...Calendar.WeekDays
...Calendar.Exceptions
The answer already provided information to get one started, but does not actually answer the question. As stated, "Exceptions" are indeed how periods of absence are defined but to determine if a given date is an absence day from the exception object will take a not-insignificant amout of parsing code.
It would be a lot simpler and much more reliable to determine workdays empirically. Assuming variable "cal" is the calendar in question declare a variable (say "d") of type long then loop from some start date to some end date-1 and determine if that date is a workday or not using Application.datedifference (d, d+1, cal). A non work day will yield 0.

VisualBasic Month function inconsistency

I'm working in a web application using VB.NET. There is also VisualBasic code mixed in it, in particular the Date variable and the Month function of VB.
The problem is this part:
Month("10/01/2008")
On the servers, I get 10 (October) as the month (which is supposed to be correct). On my machine, I get 1 (January) (which is supposed to be wrong).
Two of my colleagues (on their own machines) get different answers, one got 1, the other got 10.
The question is, why is this so?
On my end, I can solve the problem by using .NET's DateTime's Parse (or ParseExact) function to force everything to be "dd/MM/yyyy" format. This works. I'm just wondering why there's an inconsistency.
Extra info: I know the parameter for Month function is supposed to be a Date variable. The code used a string as parameter, and Option Strict was off, and the developers mainly let VB do its own conversion thing. (Legacy code maintenance has a lot of inertia...)
If it helps, the version of Microsoft.VisualBasic.dll on the servers is 7.10.6310.4 (under the Framework folder v1.1.4322). The version on mine (and my 2 colleagues') machine is 7.10.6001.4.
Edit: Regional settings for all machines already set to dd/MM/yyyy format (short date format).
This normally has to do with the regional settings, and more specifically the date/time formats. If you set these formats so that they are all the same on the machines you're testing on, the results should be consistent.
Your idea of using ParseExact is definitely the better solution to go with, IMHO.
This is because the runtime has to convert your given value "10/01/2008" which is indeed a string implicitly to the DateTime datatype.
When converting strings to dates and the other way round, the string format depends on the locale settings of windows.
See this link on msdn.
In this article a way to specify a date literal which is independent of your locale settings:
Just enclose the date with the sign # and specify it in the form mm/dd/yyyy:
So the code
Month(#10/01/2008#)
should give you the answer 10 on any machine.
Ther a two more worarounds given in that msdn article:
1. Use the Format Function with predifned Date/Time Format
To convert a Date literal to the
format of your locale, or to a custom
format, supply the literal to the
Format Function, specifying either
Predefined Date/Time Formats (Format
Function) or User-Defined Date/Time
Formats (Format Function). The
following example demonstrates this.
MsgBox("The formatted date is " &
Format(#5/31/1993#, "dddd, d MMM
yyyy"))
2. Use the DateTime-Class Constructor to construt the right DateTime value
Alternatively, you can use one of the
overloaded constructors of the
DateTime structure to assemble a date
and time value. The following example
creates a value to represent May 31,
1993 at 12:14 in the afternoon.
Dim dateInMay As New
System.DateTime(1993, 5, 31, 12, 14,
0)