|
|
Line 11: |
Line 11: |
| end | | end |
|
| |
|
| --Takes a short date and converts it to a long date (12-18-392 to Tymust 18, 392)
| | function p.test(date2) |
| function p.solandria(date2) | |
| --Splits the date
| |
| date2 = Split(date2, "-")
| |
| --Saves the parts of the date into month day year variables
| |
| month = tonumber(date2[1])
| |
| day = date2[2]
| |
| year = date2[3]
| |
|
| |
| --Takes the month variable and converts it to its text counterpart
| |
| if month == 1 then
| |
| month = "Miry"
| |
| elseif month == 2 then
| |
| month = "Ozdary"
| |
| elseif month == 3 then
| |
| month = "Rydust"
| |
| elseif month == 4 then
| |
| month = "Iptust"
| |
| elseif month == 5 then
| |
| month = "Tosey"
| |
| elseif month == 6 then
| |
| month = "Iverly"
| |
| elseif month == 7 then
| |
| month = "Eohe"
| |
| elseif month == 8 then
| |
| month = "Kasgust"
| |
| elseif month == 9 then
| |
| month = "Andust"
| |
| elseif month == 10 then
| |
| month = "Bepry"
| |
| elseif month == 11 then
| |
| month = "Nindust"
| |
| elseif month == 12 then
| |
| month = "Tymust"
| |
| elseif month == 13 then
| |
| month = "Ekage"
| |
| elseif month == 14 then
| |
| month = "Aphly"
| |
| elseif month == 15 then
| |
| month = "Asust"
| |
| elseif month == 16 then
| |
| month = "Syranust"
| |
| else
| |
| error("invalid opperation")
| |
| end
| |
| | |
| --Takes the text month variable and adds it to the day and year variable with a comma
| |
| date2 = month.." "..day..", "..year
| |
| return date2 | | return date2 |
| end | | end |
|
| |
|
| |
| --Calculates an age based on two given dates
| |
| function p.solandriaBirthDateAge(birthDate, currentDate)
| |
| --Converts the first given date to a long date
| |
| convertedDate = solandria(birthDate)
| |
|
| |
| --Splits the first date given
| |
| birthDate = Split(birthDate, "-")
| |
| --Saves the parts of the first date given into seperate month day year variables
| |
| birthMonth = birthDate[1]
| |
| birthDay = birthDate[2]
| |
| birthYear = birthDate[3]
| |
|
| |
| --Splits the second date given
| |
| currentDate = Split(currentDate, "-")
| |
| --Saves the parts of the second date given into seperate month day year variables
| |
| currentMonth = currentDate[1]
| |
| currentDay = currentDate[2]
| |
| currentYear = currentDate[3]
| |
|
| |
| --Compares the second and first date month to determine which age calculation to use
| |
| if currentMonth > birthMonth then
| |
| age = math.floor(currentYear - birthYear)
| |
| elseif currentMonth == birthMonth then
| |
| if currentDay >= birthDay then
| |
| age = math.floor(currentYear - birthYear)
| |
| elseif currentDay < birthDay then
| |
| age = math.floor(currentYear - birthYear - 1)
| |
| else
| |
| error("Something went wrong")
| |
| end
| |
| elseif currentMonth < birthMonth then
| |
| age = math.floor(currentYear - birthYear - 1)
| |
| else
| |
| error("Something went wrong")
| |
| end
| |
|
| |
| --Takes the first date and adds the age to the end
| |
| dateAge = convertedDate.." (age "..age..")"
| |
| return dateAge
| |
| end
| |
|
| |
| return p
| |
| --print(solandria("1-2-3"))
| |
| --print(solandriaBirthDateAge("12-18-392", "11-22-400"))
| |