Calendar Functions

BlitzMax Forums/BlitzMax Programming/Calendar Functions

Banshee(Posted 2005) [#1]
Dear Technical Helpers & Saviours,

I need to display a calender onscreen where I can specify the month & year and year and it displays the date's in the right row for the day and column for the week. So I guess a bit like the motorbike monthly ones on your office wall's but without the half naked woman.

I need a way of working out what day of the week the 1st falls on, and I thought one way to do this would be to set the date to the 1st of whatever month i'm looking up, reading the day with =systemDate() and then setting the date back again.

Unfortunately I cannot find a date command in BMax and I cannot execute a DOS prompt command because it is a multiplatform program (PC/MAC).

Does anyone know of a good way to solve this, or am I reduced to calculating the date based upon iteration from a known date?

Thank you :)


tonyg(Posted 2005) [#2]
Currentdate$() will get the date then there's a complicated algo to work out the day.


Floyd(Posted 2005) [#3]
Zeller's congruence gives the day of the week.
Local dayName$[] = ["Sat","Sun","Mon","Tue","Wed","Thu","Fri"]

Print
Print "Day name for Dec 8, 2005 is " + dayName[ Zeller( 2005, 12, 8 ) ]


Function Zeller( year%, month%, day% )  ' January = 1, February = 2...
                                        ' Returns 0 for Saturday, 1 for Sunday...
   If month < 3
      month :+ 12
      year :- 1
   End If

   century = year / 100
   year = year - 100 * century

   z = day + ( (month+1) * 26 ) / 10 + year + year/4 + century/4 - 2*century

   z :Mod 7
   If z < 0 Then z :+ 7
   Return z

End Function



Beaker(Posted 2005) [#4]
I was hoping that Bmax would have a calendar gadget built-in. As Purebasic shows it is possible to do this cross-platform. It looks like this:


I wonder if its possible to create a DLL (and the equivalent for Mac/Linux) from PB to do this.


Banshee(Posted 2005) [#5]
Thank you so much for that snippet Floyd it should prove most useful :)