-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|239|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- Socoder -> Blitz -> Finding day's name? Posted : Monday, 15 October 2007, 05:25 spinal I am trying to reliably find a day of the week. After looking at a hand full of algorithms on the new, trying them, failing, I have done it the simplest way i could. ; simple day calculator ; because all those fancy algorythms ; dont work properly For me. Dim day_name\$(6) For t=0 To 6 Read day_name\$(t) Next Dim month_length(23) For t=0 To 23 Read month_length(t) Next day=1 ; current day year=7 ; current year month=3 ; current month wday=6 ; Jan 1 2000 was a saturday leap=0 ; 2007 is not leap year For y=0 To year For m=1 To month For d=1 To month_length(m-1+(leap*12)) wday=wday+1 If wday=7 Then wday=0 If y=year And m=month And d=day+1 Then today=wday Next Next Next Print day_name\$(today) WaitKey() End ; day names 0=sunday 1=monday etc Data "sunday","monday","tuesday","wednesday","thursday","friday","saturday" Data 31,28,31,30,31,30,31,31,30,31,30,31 ; normal year Data 31,29,31,30,31,30,31,31,30,31,30,31 ; leap year --v It seems accurate enough, but can someone double check it? -=-=- Check out my excellent homepage! Posted : Monday, 15 October 2007, 07:22 Phoenix To me, your code seems to be working fine. If you have any problems then perhaps you should try out this: www.blitzbasic.com/codearcs/codearcs.php?code=2081 Posted : Monday, 15 October 2007, 17:46 spinal Excellent! That page has the first day-finding code I have tried that actually worked! Function GetDayOfWeek\$(day,month,year, mode% = 2) a = (14 - month)/12 y = year - a m = month + 12*a - 2 d = (day + y + y/4 - y/100 + y/400 + (31*m)/12) d%= ((d Mod 7) + 1) Return d% End Function --v I also translate it to C for my menu. int Day(int day,int month,int year) { int a = (14 - month)/12; int y = year - a; int m = month + 12*a - 2; int d = (day + y + y/4 - y/100 + y/400 + (31*m)/12); return ((d % 7) + 1); } --v -=-=- Check out my excellent homepage! Posted : Tuesday, 16 October 2007, 06:11 spinal IT for the DS, I'm fairly sure the firmware takes care of those tings. -=-=- Check out my excellent homepage! Posted : Monday, 15 April 2019, 03:51 spinal Wow! Good job this was here, I had this exact problem on a new platform. It seems there is very little resources for correctly calculating the day of the week, all you get is API calls (which in my current case, returns completely the wrong day). 12 years later and libraries still have the same issues... -=-=- Check out my excellent homepage! Posted : Tuesday, 16 April 2019, 02:11 TomToad This is from one of the first programming books I bought. Weekday. From a collection of BASIC games published in Creative Computing magazine.