Show PersianCalendar DateTimePicker using Devexpress DateEdit - asp.net-mvc

I want to insert a Persian DateTimePicker in a page view in mvc3 using devexpress DateEdit Component.
I have read and use this article to set PersianCalendar as the current calendar of CurrentCulture. It was as easy as set this code in Global.asax:
protected void Application_BeginRequest(object sender, EventArgs e)
{
var persianCulture = new PersianCulture();
Thread.CurrentThread.CurrentCulture = persianCulture;
Thread.CurrentThread.CurrentUICulture = persianCulture;
}
everything is OK when i use standard builtin calendar: <asp: Calendar ... but it getting odd when i use Devexpress DateEdit component.
month names changed correctly.
Abbrivated Day Names changed correctly.
start day of week changed correctly.
but DaysInMonth remain as it was in Gregorian calendar. for example in PersianCalendar first six months in a year have 31 days and 5 other months have 30 days and the last month have 29 days (and 30 days if it was leap year).
i had very hard time to trace what happened in DevExpress javascript codes and i only find a few things:
It use javascript Date object to manipulate date. (so what is used for standard builtin asp calendar?)
It use an array of View object to load each month in clientside.
does anyone knows whats going on in the standard builtin calendar of Asp.Net so that it can shows calendar such nice?
could you guys please get me to the right direction? i don't know what other information should i provide. so tell me if it's needed.

Related

fullcalendar - Set current date based on timezone

There have been a couple of similar questions in the past, but none I've found have been fully answered so let me try again.
I'm writing this web app where users can select their particular timezone, which might be different from the one set up in their respective system. Say my computer is set to the "America/New_York" timezone. If I (for whatever reason) set up my timezone configuration to "Asia/Tokyo" within the web app, I would like to:
have the current month aligned with the configured timezone ("Asia/Tokyo") and
have the highlighted current date also set to the "Asia/Tokyo" timezone.
I've tried many different configurations without any luck...
$("#calendar").fullCalendar({
defaultView: "month",
timezone: "Asia/Tokyo",
ignoreTimezone: false,
defaultDate: moment("2019-03-10"),
header: {...
In this case, I'm hard coding the defaultDate for tomorrow ("2019-03-10") to see if the current date highlight changes to no avail.
Is there a way to accomplish these two issues?
Update:
Okay, the answer to question (2) I found to be the parameter now. In this case, things would look like...
$("#calendar").fullCalendar({ defaultView: "month", now: moment().tz("Asia/Tokyo"), ...
As explained above, if say, my laptop is said to be configured with the "America/New_York" timezone, but I'm actually in Japan and my web app config reflects that, it won't matter. fullCalendar will now show the correct day for Today.
Still, the question remaining is (1): How to make the (monthly) calendar days be in sync with a given timezone? Thanks!

Grails make one g:datePicker depend on other g:datePicker

imagine that you have an index.gsp with two dates: Starting day and Ending Day.
When the user picks the starting day, how can I calculate + 2 months in the ending day?
I know in the controller I could have something like:
use (TimeCategory) {
c = new Date() + 2.month
}
But how is the best way to change the Ending Day in the gsp? With remoteFunction?
EDIT:
Yes it worked, thank you very much lukelazarovic.
Like you said the only thing needed to change was the last line, I changed to: $("#myid_month").val(month+3);
function dateWasChanged(){
....
$("#myid_month").val(month+3);
}
EDIT2:
I also needed to increment year, for some reason they are strings so remember to do:
myInteger = parseInt(myString);
I assume you want to do it on the client - without reloading page +2 months date is set into the end date datePicker.
That means you have to do it using Javascript or Javascript-based framework (JQuery).
You can go along with the solution suggested in this SO question: Get Date value from Grails DatePicker
Only change would be to set the value of end datePicker on the last line of function dateWasChanged like this:
$("#endDatePickerId").datpicker("setDate", date);

Select Active Tab By Date

This question was posed about selecting the active tab by weekday https://stackoverflow.com/a/7681679/1339863.
I'm sure this can be done for the month as well, but I have searched and haven't been able to find the proper application. I'm so new to jquery I can't figure out how to alter the code to suit my needs. Please Help!
you can adapt the previous code in the stackoverflow archive, just you need to extract months from date, use this code:
var date = new Date();
var months = date.getMonth();

ASP.NET MVC Calendar Design

I want to design a calendar in asp.net mvc and I want to take month information as a string in address bar. What should I do? And after that I have to show this month from index.aspx. How can I do this?
It's a little unclear what you're trying to do. If you're trying to present a calendar so that a user can input a date, I'd use jQueryUI's datepicker. The default style looks pretty nice, it's simple to use, and it works really well.
After re-reading your question, it seems you want your URL to be in some sort of date format. If this is the case, you need a custom route, like the one in this article. After you have created your custom route, printing the date is rather simple: pass the month part of the date from your controller down to your view and display it.

Sharepoint 2007 - Displaying current date in a custom list

I have been reading blog after blog about displaying the current date in a sharepoint list and nothing seems to work. I do not have administrative rights to my sharepoint server but I was able to combine some java scripts and was able to display the current date (that change each day) in a custom list. My problem is that my success is only half full and I need someone's help to figure out the rest. Here it goes:
1. I created a column in my list called "DateField", I use the calculation field with ="<B></B>
as the calculation
2. I created a Content Edit WebPart and use the source below:
<script type="text/javascript">
var currentTime = new Date()
var month = currentTime.getMonth()+1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var CurrentDate = month + "/"+ day + "/" + year
$(document).ready(function(){
$(".ms-vb2:contains('<B')").each(function(){
var tempB = document.createElement ("B");
tempB.style.cursor = "pointer";
tempB.innerHTML = $(this).text();
$(this).text(CurrentDate);
$(this).append(tempB);
});
});
</script>
The script works and the date changes each day but I cannot use the date for anything. For some reason it only sees the HTML tags in the field but it displays the current date in the column on the list. Can someone help me figure out how I can store the actual date in the column?
Thanks
Ramon
If you want to store the current date field on the column to be reused
that means that you will have to modify all the items every day with today's date.
Is that what do you really need ? it could be achieved with some ajax call to the web services (if you have update permissions for those items).
However I don't really understand your scenario.
Could you elaborate ?
My solution was to create a custom field type for the column, which would always return the current date (and time if needed). This produced the desired effect - the current date (and time) would be displayed on the front end, but still available for use in other fields in the back end.
A quick Google for examples (my code is two jobs behind me, and I haven't touched MOSS in 6 months) gives me http://vspug.com/nicksevens/2007/08/31/create-custom-field-types-for-sharepoint/
Good luck!
Regards
Moo

Resources