FullCalendar call gotoDate and set firstDay programatically - fullcalendar

I have added a custom button to the header of the calendar that has each month of the year in it. The idea is that you can select the month and the calendar will jump to that month.
I currently have firstDay set to 1 to start the calendar on a Monday, this is because in most scenarios I do want Monday to be the first day. When I call gotoDate I would like the calendar to jump to that date with it being the first visible day on the calendar; it should always be the 1st of the selected month.
Currently it goes to the date but the firstDay is Monday of that week.
I have searched to see if I could find anyone else trying to achieve this and came across the this issue but this was for quite an old version of FC, I am using 2.7
Is there a way to pragmatically set the firstDay without forking the calendar and changing the internal code?
Any help would be greatly appreciated.
*I haven't included any code because I don't think it would add any value to the question. I am not calling anything to set the firstDay other than when it is initialised.

I have found that as of version 2.9, released on the 11th July 2016 support has been added for getting and setting options dynamically.
I have upgraded from version 2.7 to 2.9 and managed to use the following code to set firstDay after the calendar is initialised.
$('#calendar').fullCalendar('option', 'firstDay', 0);
The documentation for Get/Set Options Dynamically, not all options can be set dynamically.
The GitHub issue that added the functionality.

Related

Function SalesTable2LineField.lineUpdateDescription has been used incorrectly

In Dynamics AX 2012, when trying to update the value of the field DlvMode or adding a new delivery address in the sales order (through the Header view), I keep getting this error:
Function SalesTable2LineField.lineUpdateDescription has been used
incorrectly
There's no customization in this method or this class.
This is something that could be debugged in 15 minutes if you had a developer. My guess would be that you are using one of these country codes:
AT,BE,CZ,DK,EE,FI,FR,DE,HU,IE,IT,LV,LT,NL,PL,ES,SE,GB,RU,MY (SalesTable_W)
BR (SalesTable_BR)
IN (SalesTable_IN)
In \Classes\SalesTable2LineField\lineUpdateDescription at the very end, immediately above the throw error... line add this:
info(strFmt("Offending table is %1 (%2)", tableId2name(tableId), tableId));
You should also add a breakpoint if that alone doesn't help and figure it out.
Then repeat the operation, and you will know the table. It's possible it's just a Microsoft bug or if \Forms\SalesTable has been modified, it could be that. You just need to debug it.

Vaadin Datefield doesn't recognize weeks in SimpleDateTime formats

My core problem is that I want to show the year's week number and the year itself in a Vaadin date-field. For example the user picks the 6th February 2018. The date-field should format its value like "06 2018".
As I understood the documentation of Vaadin 7.7.13, this should easily possible with:
public class CalendarWeekField extends DateField {
public CalendarWeekField() {
super();
this.setLocale(UI.getCurrent().getLocale());
this.setDateFormat("ww yyyy");
this.setShowISOWeekNumbers(true);
}
Please recognize the line this.setDateFormat("ww yyyy"); since it contains the actual "magic".
The date and time are normally displayed according to the default
format for the current locale (see Locale). You can specify a custom
format with setDateFormat(). It takes a format string that follows the
format of the SimpleDateFormat in Java.
However, following the above example, the output of the DateField is only " 2018".
What do I need to consider to get the year's week numbers displayed?
Consulted documentations:
Java SimpleDateFormat
Vaadin Date and Time Input with DateField - Date and Time Format
Vaadin 7.7.13 API Documentation DateField - setDateFormat(...)
I would call this a bug, your code is fine. You can even "fiddle around" with their live sampler (hit properties -> date format), the field excepts most date patterns but ww (and apparently some timezone-properties). File a bug report maybe?
Maybe you can walk around it by applying a change listener and using .setText() yourself? You would not need to extend the DateField in that case (actually there is no need to extend the field in the first place, simply create and set your properties).

Fullcalendar shows wrong day in month view

I'm using Fullcalendar within a Asp.Net project and I'm using the function 'events' to refresh items in my calendar.
I'm putting events in myArray to pass it in the callback function as below:
var event = {
title: 'Disponível',
start: moment(horario.DtInicio),
end: moment(horario.DtFim),
}
myArray.push(event);
where horario.DtInicio and horario.DtFim is a Asp.Net json Date (eg. "/Date(1423321200000)/")
When I show callendar in month view, this date shows in 02/06/2015 (mm/dd/yyyy), but when I toggle to other view, this event shows in 02/07/2015. The real date is 02/07/2015.
Has anyone faced this situation?
Try to set the timezone for the calendar:
$('#calendar').fullcalendar({
timezone : 'local',
...
});
As RodrigoDela suggested, try setting your timezone. If that does not help, then try what worked for me.
Setting the timezone alone to "local" did not fix the issue for me. Updating moment.js from 2.8.3 to 2.8.4 did fix the issue.
For reference, I am running the following versions of FullCalendar and its dependencies:
FullCalendar 2.2.6
jQuery 2.1.3
jQuery UI 1.10.4
moment.js 2.8.4
Additional details regarding my debugging process and fix here.

ASP.Net Razor Days between dates

I am working on a project and I need to calculate the days between date account created and current date. my code works how ever it is not giving me just the days. This below code
#(item.AccountCreated.AddYears(1)-DateTime.Now)
gives me this result like this 330.06:53:24.6752284 when all I want to be displayed would be 330 is there a way to do this through Razor.
Issue now resolved by doing
#Convert.ToInt32(((item.AccountCreated.AddYears(1)-DateTime.Now).TotalDays))
#((item.AccountCreated.AddYears(1)- DateTime.Now).TotalDays)

How can I manipulate the post date in Ghost using the Momentjs 'add' function

I've just started a Ghost.org blog and I want the blog post dates to display one year ahead of when they were actually written. I know Ghost uses Moment.js and I am able to adjust formatting (DD MM YYYY, YY MM DD etc...) but it doesn't seem to accept the 'add' function described in the Moment.js docs.
This is the code I currently have.
<time datetime="{{date format="YYYY-MM-DD"}}">
{{date format='DD MMM YYYY'}}
</time>
To be clear, I want the blog post dates to remain accurate in ghost. I simply want to manipulate what gets DISPLAYED to the user as 1 year ahead.
EG. I write a blog post and it's post date is 20th Dec 2013. I want the date on the blog post to DISPLAY 20th Dec 2014.
The Ghost {{date}} helper does not seem to accept the 'add' function.
Any help would be really appreciated. I am still learning javascript, so there may be something obvious I'm missing. I apologise if that's the case.
I guess it's a bit late for you but it might help other people.
I found a way to edit the date in the casper view. It's more a hack than a real solution. But I wanted to be able to modify the date language without modifying the core. So here is my solution:
You need to add moment js in the casper template to do so you need to download it on the website and place it in the asset folder.
Place http://momentjs.com/downloads/moment-with-locales.min.js in /content/theme/casper/assets/js/
Then you need to call it in you /content/theme/casper/default.hbs
Add this line at the bottom of the file just before the index.js one.
<script type="text/javascript" src="{{asset "js/moment-with-locales.min.js"}}"></script>
Finally add this code in /content/theme/casper/assets/js/index.js just after the line
$document.ready(function () {
like this :
var dates = $('.post-date');
var i = 0;
var postDate = moment();
for(i=0;i<dates.length;i++){
postDate = moment(dates.eq(i).html());
postDate.add(1,'year');
dates.eq(i).html(postDate.format('LL'));
}

Resources