stay on current month - fullcalendar

When I am in the month view of FullCalendar, then say I go back a few months to March and click on an event, then hit the browser 'back' button, how can I make it so that the browser knows to go back to March? Currently, it just goes back to the current month.
Thanks

Here is one possible solution:
From eventClick callback, when you redirect the user to the other page. Also send current day, month and year of the calendar in the URL.
On that page get the values from URL and store them in session variables.
This is how you can get current date of the fullCalendar:
var calCurrDate = $('#calendar').fullCalendar('getView').start;
var date = calCurrDate.getDate();
var month = calCurrDate.getMonth();
var year = calCurrDate.getFullYear();
Now on calendar page check if those session variables are defined. If they are defined, add the following properties to fullCalendar
<cfif isDefined('SESSION.d')>
<cfoutput>
date: #SESSION.d#,
month: #SESSION.m#,
year: #SESSION.y#,
</cfoutput>
</cfif>
For server side language I've used Coldfusion (as I know only this). You can easily understand the logic and translate it to your desired language.
Note: At the end of the calendar page you must destroy the session variables. Otherwise every time when you refresh the page you'll be taken to the same day, month and year.
I hope this helps. Thanks

Related

FullCalendar.io - Get All Events

I'm using the standard FullCalendar Events(as a json feed) and have everything working fine...almost.
var calendar = new Calendar(calendarEl, {
events: '/myfeed.php'
});
My initial view is a 'dayGridMonth' so the FC default behavior is to only retrieve the events for that month by appending the startParm/endParam querystring.
This is not what I want.
On the backend of this request, I'm currently sending the entire calendar feed (ignoring the start/end params) so I don't have to keep hitting my AJAX '/myfeed.php' page every time somebody clicks on "Next" to view the next month.
However, I can't get FullCalendar to know that it already has the whole json feed and not to bother getting anything else - just show the next month from the data we have. I've played around with lazyFetching but that seems to force that it goes to the AJAX call every time.
Any ideas on how I do this?
Thx!

Fullcalendar Start Hour Setting by the Time of Current Hour

I am trying to use Fullcalendar in AngularJS.
I somehow implemented the calendar and it works (saves data to the SQL).
However, if I click on the day in the calendar, the modal pops up and the start date shows 00:00:00 in time aspect.
My questions is how can you set the time for the hour of current time?
If it is 9AM currently, then, how can the time in the start initialize the time as 09:00:00 ?
This is what I have for the coding.
select: function(start, end) {
$('#ModalAdd #start').val(moment(start).format('YYYY-MM-DD HH:mm:ss'));
$('#ModalAdd #end').val(moment(end).format('YYYY-MM-DD HH:mm:ss'));
$('#ModalAdd').modal('show');
}
I have a feeling that it would be nice to somehow modify the code below and place it within the above code, but I am stuck on where to put it.
var time = new Time();
var h = date.getHour();
I don't know it the Time() even works (it was Date() from other source).
Please can anyone help me on initializing the hour in the Fullcalendar based on the current hour? I am looking for any advice or even a hint to solve this matter.
Thank you in advance!
You can use momentJS to add the current (local) system time to the selected day:
select: function(start, end) {
var today = moment();
start.set({ hours: today.hours(), minute: today.minutes() });
$('#ModalAdd #start').val(start.format('YYYY-MM-DD HH:mm:ss'));
$('#ModalAdd #end').val(end.format('YYYY-MM-DD HH:mm:ss'));
$('#ModalAdd').modal('show');
}
See https://momentjs.com/docs/#/get-set/set/
Also it's worth mentioning that start and end are already moments, so you don't need to wrap them in the moment constructor again as you were doing before.
Another thing to consider if you do this, is whether your calendar has other views available, in particular the agenda-style views, on which selections can be made which would trigger the modal? If so, then you need to ensure that the time-manipulation code above only runs when the view is "month", because the agenda view will, by default, already use the time that the user actually chose on the calendar.

ASP.NET DateTime Column in Database Getting Set to Current Date on Page Load

I'm trying to solve an issue where a database column is getting set when navigating to a page in an ASP.NET site. This is a quote management web application, and when opening a quote and navigating to a certain page, the "Expiration Date" is automatically updated to the current date. I have verified that this is occurring prior to triggering the Page_Load function in the ascx.cs file. I have tried to trace what is being run prior to this, but I'm afraid my knowledge of ASP.NET is insufficient, and I don't know exactly where to look. From the pieces I can tell are run prior (for example, the aspx.cs file), I see nothing to indicate any alterations to the record.
When I dig deeper, it seems almost as if the change is taking pace upon leaving the main landing page when editing a quote. If I update the value and travel to any page for the quote except for the main page, it stays the same. And I can travel to the main page, check the record in the database, it stays the same. But it seems like as soon as I navigate from that main page, the Expiration Date will change to the current date. Is there somewhere I can check to see if that's what's happening?
-- EDIT --
Maybe a detail list of actions might help...
View list of quotes in system
Click "Edit" link for quote
View "Quote Details" page, which is first page upon edit access
Look at database query for quote to see exp date is still proper
value
Click "Quote Options" navigation link
See expiration date in "Quote Options" has now changed to current
date
Check database query to see that without performing a known save to
the database the exp date value has updated in the database
Perform update to quote to reset exp date
View any other page in quote edit, return to "Options", see exp
date has not changed again from reset value
Verify proper date with database query
Revisit "Details" page
Again verify correct date with database query
Travel to any other page and then to "Options", or go straight
to "Options", see that exp date has changed to current date
This is the HTML on the link used, which appears to be identical on the other pages...
<a class="tabOff" id="ContentPlaceHolder1_linkButtonAddEditShipping" href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ctl00$ContentPlaceHolder1$linkButtonAddEditShipping", "", true, "", "", false, true))'>Quote Options</a>
I solved the problem. Sort of. I did discover that the save function was being triggered when leaving the "Details" page, even though no save action was being explicitly activated. The problem was resolved by getting the expiration date from the database at the beginning of the function, and if one was set, pushing that value back in at the very end of the function. While this has in effect prevented the value from being "overwritten", I am still unable to determine why the save function was being triggered, and unable to determine what actions within that function are setting the value to be the current date

What is the best way to get the date and time in server side?

I'm developing an asp.net mvc3 project. I have a trouble in this problem that I encounter. I will give a scenario so that it will understand well.
Scenario:
I have 2 PC (PC1(server) and PC2(client)). For example both two PC has different date and time let say for PC1 is +8GMT Date 8/10/2016 and for PC2 +8GMT Date 8/9/2016. I am using the PC2 the client and i'm using a code for getting the time is DateTime.Now(); in my controller and the time is display in label in one of my views. I tried to adjust the Date and Time of the PC2 the label for displaying t he time also change. What I want is even I change the Date and Time in PC2 it won't affect/change the displayed Date and Time in my label it will stick on what the Date and Time in the PC1.
This scenario is i'm using/testing the publish project
Any suggestions are welcome.
I'm not sure if I understand the question, but you might consider looking into the DateTime.ToUniversalTime method, which converts the value of the DateTime object to UTC.
This way, you may be able to work with a standard time from which you can convert to any time zone you might want to use to display in your application, regardless of server location.
DateTime serverTime = DateTime.Now;
DateTime utcTime = serverTime.ToUniversalTime;
string timeZoneId = "some time zone id";
TimeZoneInfo myTime = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId);
DateTime label = TimeZoneInfo.ConvertTimeFromUtc(utcTime, myTime);
I am not very clear on your description. It seems as if you want your label to always show the time on the server (PC1) when the web page is loaded on the client by calling the site on the server, maybe like https://pc1. What you're doing should accomplish that: the time displayed in your label will be the system time from the server. Changing the time on the client will not affect it.
If you want your client (PC2) to show its local time, you will need to use code that runs on the client, i.e. JavaScript in most cases.
Working with dates in Javascript can be a little different from other languages/expectations, so I suggest reading the docs at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date.
Get started with var currentDate = new Date();.

events (as a json feed), start end parameters unix timestamp, are different if I change my OS time zone

I'm using the fullcalendar plugin and would appreciate if someone can give me a hand.
I am getting json events through a PHP URL.
something like this:
$('#calendar').fullCalendar({ events: "/myfeed.php" });
So in my php page that returns the events, I am getting 3 GET parameters:
'_'
'start'
'end'
The start and end parameter, indicate the date in UNIX timestamp.
So far so good, the problem that occurs is that if I change the time zone on my OS. also change these parameters start and end, for the same query in the same day in the calendar.
the weirdest part is that it only happens in Mozilla Firefox.
in Google Chrome, this problem does not occur.
e.g.
I have set my time zone ((UTC-04: 00) Santiago)
I'm referring to the day 09.09.2012 on the agenda,
firebug shows me that these parameters are being sent to my php page
_ 1347245953581
end 1347246000
start 1347159600
but if I change the time zone from my OS to ((UTC-03: 00) Buenos Aires)
consulting on 09.09.2012 on the agenda,
are other parameters which are now sent to the PHP page.
_ 1347246338047
end 1347332400
start 1347246000
Being that it is the same day, are other start and end parameters which are sent to check for events.
There is an ignoreTimezone option on the fullcalendar that might help. I'm not sure if it affects the start/end time passed to the feeds.
http://arshaw.com/fullcalendar/docs/event_data/ignoreTimezone/
Another option is to convert the passed timestamp to a Date object and get the local data from the Date object afterwards and use that in your queries.
Convert a Unix timestamp to time in JavaScript
I know it is not the exact answer, but it might help you out a bit.
Here is a sample piece of PHP code to convert the passed timestamp into a local formatted date:
$startts = $_REQUEST["start"]; // original timestamp
$startdt = new DateTime('now', new DateTimeZone('Europe/Oslo') ); // setup a local datetime
$startdt->setTimestamp($startts); // Set the date based on timestamp
echo $startdt->format('Y-m-d H:i:s'); // Output local date and time

Resources