This is what I currently have, but if it's correct or not, I don't know, didn't had the time yet to test it.
Code: Select all
DIM SHARED DayNames(1 to 7) AS STRING
DIM SHARED Months(1 to 12) AS INTEGER
DayNames(1) = "Thu" 'I know, I know, this has to be Sunday, but make
DayNames(2) = "Fri" 'things a bit easier, and since the 1st of January
DayNames(3) = "Sat" '1970 was a Thursday, it's easier this way.
DayNames(4) = "Sun"
DayNames(5) = "Mon"
DayNames(6) = "Tue"
DayNames(7) = "Wed"
Months(1) = 31
Months(2) = 28 'Unless we have a leapyear, hehehehe
Months(3) = 31
Months(4) = 30
Months(5) = 31
Months(6) = 30
Months(7) = 31
Months(8) = 31
Months(9) = 30
Months(10) = 31
Months(11) = 30
Months(12) = 31
FUNCTION GetDay$ (dValue%, mValue%, yValue%)
'dValue% = day, mValue% = month, yValue% = year
'Fine, the hard way (atleast I think it is)
'Whatever happend before 1970, not important, we start at 1970
'We know, atleast I do, that the 1st of January 1970 was a Thursday.
Getdayyear% = 1970
Getdaymonth% = 1
Getdayday% = 1
Getdaydayname$ = DayNames(1)
'Let's get the years between 1970 and yValue%
YearsInPeriod = yValue% - 1970
'There are leapyears... who ever thought of those... Argh!!
'Anyways, here's sumfin I found out, which hopefully really works!!
LeapyearsInPeriod = YearsInPeriod / 4 'This gives a value
FOR a = 1 TO LEN(LTRIM$(RTRIM$(STR$(LeapyearsInPeriod))))
IF MID$(LTRIM$(RTRIM$(STR$(LeapyearsInPeriod))),a,1) = "," THEN
'if it contains a comma, we only want the value in front of the comma.
LeapyearsInPeriod = LEFT$(LTRIM$(RTRIM$(STR$(LeapyearsInPeriod))), a - 1)
END IF
NEXT A
'Since this is a beta version which probaly sum bugs... NVM.
'Anywayz, in order to get the days right, we use the LeapYearsInPeriodvalue
'and add this to the days of the week... Later on...
'Okay, we've gotten this far. Lets see if we can do the rest.
'First bring the year back to were we need to be...
'Back... to the future...
'This is a week calculation some how... you'll see...
Socalledweeks% = YearsInPeriod / 7
FOR a = 1 TO LEN(LTRIM$(RTRIM$(STR$(Socalledweeks%))))
IF MID$(LTRIM$(RTRIM$(STR$(Socalledweeks%))),a,1) = "," THEN
'if it contains a comma, we only want the value in front of the comma.
Socalledweeks% = LEFT$(LTRIM$(RTRIM$(STR$(Socalledweeks%))), a - 1)
END IF
NEXT A
'okay what now... how many days left...
daysleftinweek% = YearsInPeriod - (Socalledweeks% * 7)
IF daysleftinweek% > 7 THEN
'for future release... hehehehe, no can do!!
ELSE
Getdayday% = dValue%
Getdaydayname$ = DayNames(daysleftinweek%-1)
END IF
'Okay... brought it to yValue%...
grtz
Seb