Time (script): Difference between revisions

From Elanthipedia
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Converts IC to Real time and vice versa.

<pre>
#####################################################
#####################################################
# #
# #
# Time - 7/17/2009 #
# Time - 7/27/2009 #
# Maje #
# Maje #
# #
# #
Line 10: Line 7:
#
#
# Converts IC to Real time and vice versa
# Converts IC to Real time and vice versa
# All times are server (CST)
#
#
# Note - Does not convert times prior to 1/1/1996
# Note - Does not convert times prior to 1/1/1996
Line 15: Line 13:
# Things to Fix:
# Things to Fix:
#
#
# Loss of 1 IC day per RL year
# Fudge factor causes formula errors near the end of REAL years
# Clean up sloppy code
# Loss of 1 day per year
#
#
# Changes:
# Changes:
#
#
# Fixed end of year wonkiness, now rolls over to new year properly
# Added IC hour instead of leaving IC days with decimal values when going Real to IC
# Added real hour time range when going IC to Real
#
#
#22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#


action setvar ICYear $1; setvar ICDay $2 when ^It has been (\d+) years, (\d+) days since the Victory of Lanival the Redeemer
action setvar ICYear $1; setvar ICTotalDays $2; setvar ICHour 0 when ^It has been (\d+) years, (\d+) days since the Victory of Lanival the Redeemer
action setvar ICMonth $1 when ^It is the (\d+)th month of (.*) in the year of
action setvar ICMonth $1 when ^It is the (\d+)th month of (.*) in the year of


Line 51: Line 52:
setvar consDecLen 31
setvar consDecLen 31


#22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#


Main:
Main:
Line 59: Line 60:
exit
exit


#22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#


Input:
Input:
Line 92: Line 93:
return
return


#22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#


Convert:
Convert:
Line 104: Line 105:
gosub Convert.ICtoReal.FindYear
gosub Convert.ICtoReal.FindYear
gosub Convert.ICtoReal.FindMonth
gosub Convert.ICtoReal.FindMonth
return


Convert.ICtoReal.CalcICDays:
Convert.ICtoReal.CalcICDays:
evalmath Days.Current %ICDay + %ICYear * 400
evalmath Days.Current %ICTotalDays + %ICYear * 400
evalmath numDays %Days.Current - %consICTotal
evalmath numDays %Days.Current - %consICTotal
return
return
Line 196: Line 198:
}
}
setvar RealMonth %tempMonth
setvar RealMonth %tempMonth
setvar RealDay %tempDays
setvar tempRealDay %tempDays
math tempDays modulus 1
evalmath RealDay %tempRealDay - %tempDays
if %tempDays < .25 then setvar RealHour 12 am to 6 am
if %tempDays >= .25 and %tempDays < .5 then setvar RealHour 6 am to 12 am
if %tempDays >= .5 and %tempDays < .75 then setvar RealHour 12 am to 6 pm
if %tempDays >= .75 then setvar RealHour 6 pm to 12 pm
return
return


Line 276: Line 284:


Convert.RealtoIC.CalcRealHours:
Convert.RealtoIC.CalcRealHours:
evalmath numDays %numDays + (%RealHour / 24)
evalmath numDays %numDays + (%RealHour / 6) - 2
return
return


Convert.RealtoIC.CalcICTime:
Convert.RealtoIC.CalcICTime:
evalmath numDays %numDays + (400 - %consICDay)
evalmath tempYear %numDays / 400
evalmath tempYear %numDays / 400
math numDays modulus 400
math numDays modulus 400
evalmath tempYear %tempYear - (%numDays / 400)
evalmath tempYear %tempYear - (%numDays / 400)
evalmath ICYear %tempYear + %consICYear
evalmath ICYear %tempYear + %consICYear
evalmath ICDay %numDays + (400 - %consICDay)
evalmath ICTotalDays floor(%numDays)
math numDays modulus 1
evalmath ICHour round(24 * %numDays)
return
return


#22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#


Report:
Report:
Line 295: Line 306:


Report.GetMonth:
Report.GetMonth:
evalmath tempMonth %ICDay / 40
evalmath tempMonth floor((%ICTotalDays / 40))
setvar numDays %tempMonth
setvar numDays %ICTotalDays
math numDays modulus 1
math numDays modulus 40
evalmath tempMonth %tempMonth - %numDays
evalmath ICDay floor(%numDays)
if %tempMonth == 0 then setvar ICMonth Akroeg the Ram
if %tempMonth == 0 then setvar ICMonth Akroeg the Ram
if %tempMonth == 1 then setvar ICMonth Ka'len the Sea Drake
if %tempMonth == 1 then setvar ICMonth Ka'len the Sea Drake
Line 312: Line 323:


Report.Print:
Report.Print:
echo IC Time: %ICMonth , %ICDay of %ICYear
echo IC Time: %ICDay %ICMonth (day %ICTotalDays) %ICYear AV - %ICHour o'clock (military)
echo Real Time: %RealMonth %RealDay %RealYear
echo Real Time: %RealMonth/%RealDay/%RealYear , %RealHour
return
return
</pre>

[[Category:Scripts]]

Revision as of 17:34, 27 July 2009

  1. #
  2. Time - 7/27/2009 #
  3. Maje #
  4. #
  5. Converts IC to Real time and vice versa
  6. All times are server (CST)
  7. Note - Does not convert times prior to 1/1/1996
  8. Things to Fix:
  9. Loss of 1 IC day per RL year
  10. Clean up sloppy code
  11. Changes:
  12. Fixed end of year wonkiness, now rolls over to new year properly
  13. Added IC hour instead of leaving IC days with decimal values when going Real to IC
  14. Added real hour time range when going IC to Real
  15. 22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)~#

action setvar ICYear $1; setvar ICTotalDays $2; setvar ICHour 0 when ^It has been (\d+) years, (\d+) days since the Victory of Lanival the Redeemer action setvar ICMonth $1 when ^It is the (\d+)th month of (.*) in the year of

action setvar RealMonth $1;setvar RealDay $2; setvar RealYear $3; setvar RealHour $4 when (\d+)/(\d+)/(\d+) (\d+)

setvar consICDay 192 setvar consICYear 345 setvar consICTotal 138206

setvar consRealMonth 1 setvar consRealDay 1 setvar consRealYear 1996 setvar consRealHour 0 setvar FudgeFactor 1537

setvar consJanLen 31 setvar consFebLen 28 setvar consMarchLen 31 setvar consAprilLen 30 setvar consMayLen 31 setvar consJuneLen 30 setvar consJulyLen 31 setvar consAugLen 31 setvar consSeptLen 30 setvar consOctLen 31 setvar consNovLen 30 setvar consDecLen 31

  1. 22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)~~#

Main: gosub Input gosub Convert gosub Report exit

  1. 22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)~~#

Input:

Input.Menu: echo Enter the number for what you'd like to convert: echo echo 1. Convert IC time to Real time echo 2. Convert Real time to IC time matchre Input.IC 1 matchre Input.Real 2 matchwait

Input.IC: setvar Input IC echo Enter the in game time text: echo echo Example - It has been 394 years, 384 days since the Victory of Lanival the Redeemer. matchre Input.Done Lanival the Redeemer matchwait

Input.Real: setvar Input Real echo Enter the real time: echo echo Use military time without minutes - July 14th, 2009 6:00 pm... echo Example - 7/14/2009 18 match Input.Done / matchwait

Input.Done: return

  1. 22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)~~#

Convert: if "%Input" == "IC" then gosub Convert.ICtoReal else gosub Convert.RealtoIC return

Convert.ICtoReal: gosub Convert.ICtoReal.CalcICDays gosub Convert.ICtoReal.CalcRealDays gosub Convert.ICtoReal.FindYear gosub Convert.ICtoReal.FindMonth return

Convert.ICtoReal.CalcICDays: evalmath Days.Current %ICTotalDays + %ICYear * 400 evalmath numDays %Days.Current - %consICTotal return

Convert.ICtoReal.CalcRealDays: setvar Days.Real.Part %numDays math Days.Real.Part modulus 4 evalmath Days.Real %numDays / 4 return

Convert.ICtoReal.FindYear: setvar tempYear 1996 setvar tempDays %Days.Real gosub Convert.ICtoReal.FindYear.CalcYear setvar RealYear %tempYear setvar RealDay %tempDays return

Convert.ICtoReal.FindYear.CalcYear: if %tempDays < 365 then return setvar tempLeap %tempYear math tempLeap modulus 4 if %tempLeap == 0 then { evalmath tempDays %tempDays - 366 } else { evalmath tempDays %tempDays - 365 } math tempYear add 1 gosub Convert.ICtoReal.FindYear.CalcYear return

Convert.ICtoReal.FindMonth: setvar tempMonth 1 if %tempDays >= %consJanLen then { evalmath tempDays %tempDays - %consJanLen math tempMonth add 1 } if %tempDays >= %consFebLen then { setvar tempLeap %RealYear math tempLeap modulus 4 if %tempLeap == 0 then { evalmath tempDays %tempDays - %consFebLen - 1 } else { evalmath tempDays %tempDays - %consFebLen } math tempMonth add 1 } if %tempDays >= %consMarchLen then { evalmath tempDays %tempDays - %consMarchLen math tempMonth add 1 } if %tempDays >= %consAprilLen then { evalmath tempDays %tempDays - %consAprilLen math tempMonth add 1 } if %tempDays >= %consMayLen then { evalmath tempDays %tempDays - %consMayLen math tempMonth add 1 } if %tempDays >= %consJuneLen then { evalmath tempDays %tempDays - %consJuneLen math tempMonth add 1 } if %tempDays >= %consJulyLen then { evalmath tempDays %tempDays - %consJulyLen math tempMonth add 1 } if %tempDays >= %consAugLen then { evalmath tempDays %tempDays - %consAugLen math tempMonth add 1 } if %tempDays >= %consSeptLen then { evalmath tempDays %tempDays - %consSeptLen math tempMonth add 1 } if %tempDays >= %consOctLen then { evalmath tempDays %tempDays - %consOctLen math tempMonth add 1 } if %tempDays >= %consNovLen then { evalmath tempDays %tempDays - %consNovLen math tempMonth add 1 } if %tempDays >= %consDecLen then { evalmath tempDays %tempDays - %consDecLen math tempMonth add 1 } setvar RealMonth %tempMonth setvar tempRealDay %tempDays math tempDays modulus 1 evalmath RealDay %tempRealDay - %tempDays if %tempDays < .25 then setvar RealHour 12 am to 6 am if %tempDays >= .25 and %tempDays < .5 then setvar RealHour 6 am to 12 am if %tempDays >= .5 and %tempDays < .75 then setvar RealHour 12 am to 6 pm if %tempDays >= .75 then setvar RealHour 6 pm to 12 pm return

Convert.RealtoIC: setvar numDays 0 setvar tempYear %consRealYear setvar tempMonth %consRealMonth setvar tempDay %consRealDay gosub Convert.RealtoIC.CalcRealYears gosub Convert.RealtoIC.CalcRealMonths gosub Convert.RealtoIC.CalcRealHours gosub Convert.RealtoIC.CalcICTime return

Convert.RealtoIC.CalcRealYears: if %tempYear < %RealYear then { setvar tempLeap %tempYear math tempLeap modulus 4 if %tempLeap == 0 then { evalmath numDays %numDays + 366 * 4 } else { evalmath numDays %numDays + 365 * 4 } math tempYear add 1 gosub Convert.RealtoIC.CalcRealYears } return

Convert.RealtoIC.CalcRealMonths: if %tempMonth < %RealMonth then { if %tempMonth == 1 then { evalmath numDays %numDays + %consJanLen * 4 } if %tempMonth == 2 then { setvar tempLeap %RealYear math tempLeap modulus 4 if %tempLeap == 0 then { evalmath numDays %numDays + (%consFebLen + 1) * 4 } else { evalmath numDays %numDays + %consFebLen * 4 } } if %tempMonth == 3 then { evalmath numDays %numDays + %consMarchLen * 4 } if %tempMonth == 4 then { evalmath numDays %numDays + %consAprilLen * 4 } if %tempMonth == 5 then { evalmath numDays %numDays + %consMayLen * 4 } if %tempMonth == 6 then { evalmath numDays %numDays + %consJuneLen * 4 } if %tempMonth == 7 then { evalmath numDays %numDays + %consJulyLen * 4 } if %tempMonth == 8 then { evalmath numDays %numDays + %consAugLen * 4 } if %tempMonth == 9 then { evalmath numDays %numDays + %consSeptLen * 4 } if %tempMonth == 10 then { evalmath numDays %numDays + %consOctLen * 4 } if %tempMonth == 11 then { evalmath numDays %numDays + %consNovLen * 4 } math tempMonth add 1 gosub Convert.RealtoIC.CalcRealMonths } else { evalmath numDays %numDays + %RealDay * 4 } return

Convert.RealtoIC.CalcRealHours: evalmath numDays %numDays + (%RealHour / 6) - 2 return

Convert.RealtoIC.CalcICTime: evalmath numDays %numDays + (400 - %consICDay) evalmath tempYear %numDays / 400 math numDays modulus 400 evalmath tempYear %tempYear - (%numDays / 400) evalmath ICYear %tempYear + %consICYear evalmath ICTotalDays floor(%numDays) math numDays modulus 1 evalmath ICHour round(24 * %numDays) return

  1. 22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)22:34, 27 July 2009 (UTC)~~#

Report: gosub Report.GetMonth gosub Report.Print return

Report.GetMonth: evalmath tempMonth floor((%ICTotalDays / 40)) setvar numDays %ICTotalDays math numDays modulus 40 evalmath ICDay floor(%numDays) if %tempMonth == 0 then setvar ICMonth Akroeg the Ram if %tempMonth == 1 then setvar ICMonth Ka'len the Sea Drake if %tempMonth == 2 then setvar ICMonth Lirisa the Archer if %tempMonth == 3 then setvar ICMonth Shorka the Cobra if %tempMonth == 4 then setvar ICMonth Uthmor the Giant if %tempMonth == 5 then setvar ICMonth Arhat the Fire Lion if %tempMonth == 6 then setvar ICMonth Moliko the Balance if %tempMonth == 7 then setvar ICMonth Skullcleaver the Dwarven Axe if %tempMonth == 8 then setvar ICMonth Dolefaren the Brigantine if %tempMonth >= 9 then setvar ICMonth Nissa the Maiden return

Report.Print: echo IC Time: %ICDay %ICMonth (day %ICTotalDays) %ICYear AV - %ICHour o'clock (military) echo Real Time: %RealMonth/%RealDay/%RealYear , %RealHour return