Difference between revisions of "User:Rasikko"

Jump to navigation Jump to search
1,196 bytes added ,  23:33, 8 September 2018
GetAnyDayOfWeek
imported>Scrivener07
(→‎Time Functions: GetHoursPassedForWeek)
imported>Scrivener07
(GetAnyDayOfWeek)
Line 97: Line 97:
</source>
</source>
--[[User:Rasikko|Rasikko]] ([[User talk:Rasikko|talk]]) 2018-09-07T16:15:58 (EDT)
--[[User:Rasikko|Rasikko]] ([[User talk:Rasikko|talk]]) 2018-09-07T16:15:58 (EDT)
<source lang="papryus">
String Function GetAnyDayOfWeek(Int day, Int month, Int year) Global
    ; returns the day of week that any day falls on for any month of any year.
    Int[] KeyValues = new Int[12]
    KeyValues[0] = 6
    KeyValues[1] = 2
    KeyValues[2] = 2
    KeyValues[3] = 5
    KeyValues[4] = 0
    KeyValues[5] = 3
    KeyValues[6] = 5
    KeyValues[7] = 4
    KeyValues[8] = 4
    KeyValues[9] = 5
    KeyValues[10] = 2
    KeyValues[11] = 4
   
    Int dayOfWeek = (29 + day + KeyValues[month] + year) % 7
    if dayOfWeek == 0
      return "Sunday"
    elseif dayOfWeek == 1
      return "Monday"
    elseif dayOfWeek == 2
      return "Tuesday"
    elseif dayOfWeek == 3
      return "Wednesday"
    elseif dayOfWeek == 4
      return "Thursday"
    elseif dayOfWeek == 5
      return "Friday"
    elseif dayOfWeek == 6
      return "Saturday"
    endif
    return ""
EndFunction
</source>
The key values represent the days of the week that the first day of every month starts on for the year 2287. The formulas involved uses those values to find the days of the week for any day. --[[User:Rasikko|Rasikko]] ([[User talk:Rasikko|talk]]) 2018-09-09T00:33:24 (EDT)
Anonymous user

Navigation menu