Day extension – ShiVa Engine

Day extension

Function/Handler NAME: GetDayExt ( nDay )
TYPE: Function
Code Created By, Date and Version: Game Scorpion Inc. – Apr-16-2012 – 1.0
SOURCES: Game Scorpion Inc.
Code Description: This function will return the STRING ending for any calender day between 1 – 31. For example, 1 = 1st, 2 = 2nd, 3 = 3rd, etc.
Function/Handler INPUTS: nDay -> An integer value between 1 and 31
Function/Handler OUTPUTS: sExt -> The extension string (st, nd, rd, th)
REQUIREMENTS: Create a function in your AI called GetDayExt and copy and paste this code into it.

--------------------------------------------------------------------------------
function MainAI.GetDayExt ( nDay )
--------------------------------------------------------------------------------
    local sExt = ""
    if nDay == 1 then
        sExt = "st"
    elseif ( nDay == 2 ) then
        sExt = "nd"
    elseif ( nDay == 3 ) then
        sExt = "rd"
    elseif ( nDay >= 4 and nDay <= 20 ) then
        sExt = "th"
    elseif ( nDay == 21 ) then
        sExt = "st"
    elseif ( nDay == 22 ) then
        sExt = "nd"
    elseif ( nDay == 23 ) then
        sExt = "rd"
    elseif ( nDay >= 24 and nDay <= 30 ) then
        sExt = "th"
    elseif ( nDay == 31 ) then
        sExt = "st"
    end
    return sExt
--------------------------------------------------------------------------------
end
--------------------------------------------------------------------------------



Need more answers?

  • slackBanner