Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » CalendarCtrl » Setting FirstDay puts day numbers out of alignment with day names
Setting FirstDay puts day numbers out of alignment with day names [message #35637] Fri, 09 March 2012 05:40 Go to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 219
Registered: June 2011
Experienced Member
I made the following changes so that when FirstDay is changed, the calendar days will realign themselves to their names. Having tested Sat-Friday, it appears to work.

I don't know how this affects the week numbers, though, because my math with date time calculation is not too good:

int	Calendar::DayOfWeek(int day, int month, int year, int zelleroffset)
{
	if(month < 3)
	{
		month += 12 ;
		year -= 1 ;
        }

	int n1 = (26 * (month + 1)) / 10;
	int n2 = (125 * year) / 100;

	return ((day + (8 - first_day) + n1 + n2 - (year / 100) + (year / 400) - zelleroffset) % 7 );
} 

[Updated on: Fri, 09 March 2012 05:45]

Report message to a moderator

Re: Setting FirstDay puts day numbers out of alignment with day names [message #35648 is a reply to message #35637] Fri, 09 March 2012 21:39 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

I found this method somewhere on the net so I'm unable to help you. Just modify it and we will see Smile
Re: Setting FirstDay puts day numbers out of alignment with day names [message #35649 is a reply to message #35648] Fri, 09 March 2012 22:22 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 219
Registered: June 2011
Experienced Member
Ah sorry, what I meant was that I already had modified it.

I just added (8 - first_day) to that last line and that seems to be the workaround. Sorry for the confusion.

If the change meets your approval, would you like to push it in?

And thanks for writing the CalendarCtrl BTW. Ultimate++ is proving very useful to me.

[Updated on: Fri, 09 March 2012 22:27]

Report message to a moderator

Re: Setting FirstDay puts day numbers out of alignment with day names [message #35650 is a reply to message #35637] Fri, 09 March 2012 22:38 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 219
Registered: June 2011
Experienced Member
Sorry, I don't think I was clear enough about the problem. The problem is that if you use FirstDay(SATURDAY) as an example, the current behavior does move the weekdays (Sa Su Mo Tu We Th Fr), but it does not shift the dates too, so you could have day 3 of the month be on a Wednesday when it's actually a Friday, etc.

Adding that small piece of code will shift the dates over so they line back up with their respective day names when you call FirstDay.
Re: Setting FirstDay puts day numbers out of alignment with day names [message #35651 is a reply to message #35637] Fri, 09 March 2012 22:49 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 219
Registered: June 2011
Experienced Member
Example:

I set FirstDay(SATURDAY):

index.php?t=getfile&id=3666&private=0

The first of March is not Tuesday, it is a Thursday. If I add the fix I showed above it shows up right:

index.php?t=getfile&id=3667&private=0
  • Attachment: Calendar.png
    (Size: 5.90KB, Downloaded 498 times)
  • Attachment: Calendar2.png
    (Size: 5.89KB, Downloaded 949 times)
Re: Setting FirstDay puts day numbers out of alignment with day names [message #35663 is a reply to message #35651] Sun, 11 March 2012 18:44 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Thank you. It's in svn now Smile
Re: Setting FirstDay puts day numbers out of alignment with day names [message #35665 is a reply to message #35663] Sun, 11 March 2012 19:12 Go to previous message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 219
Registered: June 2011
Experienced Member
Thanks, man! Smile
Previous Topic: DropTime and WhenAction() problem
Next Topic: [Minor bug & patch] CalendarCtrl should offer support for native cursor icon.
Goto Forum:
  


Current Time: Thu Mar 28 13:55:23 CET 2024

Total time taken to generate the page: 0.01084 seconds