# time !! Calculate the number of the current day since the start of the game. if $ARGS[0] = '': !! total amount of minutes since the start of the game prevtotmin = totminut ! sync totminut with daystart, hour, and minut totminut = minut + hour * 60 + (daystart - 1) * 1440 :time_time_loop time_temp_jump_flag = 0 if minut >= 60: !! Hourly Changes hour += 1 minut -= 60 gs 'hourly_events' time_temp_jump_flag = 1 end if hour >= 24: hour -= 24 daystart += 1 gs 'time', 'update_date' gs 'cikl' time_temp_jump_flag = 1 end if time_temp_jump_flag = 1: jump 'time_time_loop' killvar 'time_temp_jump_flag' end if $ARGS[0] = 'update_date': gs 'time', 'to_date', daystart day = dateVars['day'] month = dateVars['month'] $month = $dateVars['month_text'] year = dateVars['year'] week = dateVars['week'] odd_week = dateVars['odd_week'] $stat_day_suffix = $dateVars['suffix'] end ! ARGS[1] = daystart if $ARGS[0] = 'to_date': !daystart = 1 -> 1 Jan 2016 !mod_daystart = 0 -> 1 Jan 2013 mod_daystart = ARGS[1] + 1094 dateVars['week'] = (mod_daystart + 2) mod 7 if dateVars['week'] = 0: dateVars['week'] = 7 dateVars['year'] = 2013 temp_4cycles = mod_daystart / 1461 & ! (cycle of 4 years) dateVars['year'] += 4 * temp_4cycles ! The remaining years in this cycle of 4 years if mod_daystart mod 1461 >= 1095: temp_inner_years = 3 elseif mod_daystart mod 1461 >= 730: temp_inner_years = 2 elseif mod_daystart mod 1461 >= 365: temp_inner_years = 1 else temp_inner_years = 0 end dateVars['year'] += temp_inner_years & ! The remaining years in this cycle of 4 years temp_inner_days = mod_daystart - 1461 * temp_4cycles - 365 * temp_inner_years temp_leapyear = 0 if ((dateVars['year'] mod 4) = 0 and (dateVars['year'] mod 100) ! 0) or (dateVars['year'] mod 400 = 0): if temp_inner_days > 59: temp_inner_days -= 1 temp_leapyear = 1 end end !temp_inner_days starts at 0! if temp_inner_days < 31: dateVars['month'] = 1 elseif temp_inner_days < 59: dateVars['month'] = 2 temp_inner_days -= 31 temp_inner_days += temp_leapyear elseif temp_inner_days < 90: dateVars['month'] = 3 temp_inner_days -= 59 elseif temp_inner_days < 120: dateVars['month'] = 4 temp_inner_days -= 90 elseif temp_inner_days < 151: dateVars['month'] = 5 temp_inner_days -= 120 elseif temp_inner_days < 181: dateVars['month'] = 6 temp_inner_days -= 151 elseif temp_inner_days < 212: dateVars['month'] = 7 temp_inner_days -= 181 elseif temp_inner_days < 243: dateVars['month'] = 8 temp_inner_days -= 212 elseif temp_inner_days < 273: dateVars['month'] = 9 temp_inner_days -= 243 elseif temp_inner_days < 304: dateVars['month'] = 10 temp_inner_days -= 273 elseif temp_inner_days < 334: dateVars['month'] = 11 temp_inner_days -= 304 else dateVars['month'] = 12 temp_inner_days -= 334 end $dateVars['month_text'] = $monthName[dateVars['month']] dateVars['day'] = 1 + temp_inner_days dateVars['odd_week'] = ((mod_daystart + 8) / 7) mod 2 if (dateVars['day'] >= 4 and dateVars['day'] <= 20): $dateVars['suffix'] = 'th' elseif dateVars['day'] mod 10 = 1: $dateVars['suffix'] = 'st' elseif dateVars['day'] mod 10 = 2: $dateVars['suffix'] = 'nd' elseif dateVars['day'] mod 10 = 3: $dateVars['suffix'] = 'rd' else $dateVars['suffix'] = 'th' end if $ARGS[2] = 'test': *nl 'new_day: <> | old_day: <>' 'new_month: <> | old_month: <>' 'new_year: <> | old_year: <>' 'new_week: <> | old_week: <>' 'new_odd_week: <> | old_odd_week: <>' *nl 'mod_daystart: <>' 'temp_inner_days: <>' 'temp_leapyear: <>' 'temp_4cycles: <>' 'temp_inner_years: <>' end killvar 'temp_inner_days' killvar 'temp_leapyear' killvar 'temp_4cycles' killvar 'temp_inner_years' killvar 'mod_daystart' end if $ARGS[0] = 'to_daystart': dateVars['day'] = ARGS[1] dateVars['month'] = ARGS[2] dateVars['year'] = ARGS[3] mod_daystart = (dateVars['year'] - 2013) * 365 mod_daystart += (dateVars['year'] - 2013) / 4 if dateVars['month'] > 1: mod_daystart += 31 if dateVars['month'] > 2: if ((dateVars['year'] mod 4 = 0) and (dateVars['year'] mod 100 ! 0)) or (dateVars['year'] mod 400 = 0): mod_daystart += 29 else mod_daystart += 28 end end if dateVars['month'] > 3: mod_daystart += 31 if dateVars['month'] > 4: mod_daystart += 30 if dateVars['month'] > 5: mod_daystart += 31 if dateVars['month'] > 6: mod_daystart += 30 if dateVars['month'] > 7: mod_daystart += 31 if dateVars['month'] > 8: mod_daystart += 31 if dateVars['month'] > 9: mod_daystart += 30 if dateVars['month'] > 10: mod_daystart += 31 if dateVars['month'] > 11: mod_daystart += 30 mod_daystart += dateVars['day'] dateVars['daystart'] = (mod_daystart - 1095) if $ARGS[4] = 'test': 'new_daystart <> | old_daystart <>' end killvar 'mod_daystart' end if $ARGS[0] = 'get_time_string': if arrsize('$ARGS') = 1: ARGS[1] = hour if arrsize('$ARGS') = 2: ARGS[2] = minut $result = '<<$mid(100 + ARGS[1], 2, 2)>>:<<$mid(100 + ARGS[2], 2, 2)>>' end !!=====================================================================================!! !! !! !! INITIALIZATION !! !! !! !!=====================================================================================!! if $ARGS[0] = 'init_monthnames': $monthName[1] = 'January' $monthName[2] = 'February' $monthName[3] = 'March' $monthName[4] = 'April' $monthName[5] = 'May' $monthName[6] = 'June' $monthName[7] = 'July' $monthName[8] = 'August' $monthName[9] = 'September' $monthName[10] = 'October' $monthName[11] = 'November' $monthName[12] = 'December' end if $ARGS[0] = 'init_weeknames': $week[1] = 'Monday' $week[2] = 'Tuesday' $week[3] = 'Wednesday' $week[4] = 'Thursday' $week[5] = 'Friday' $week[6] = 'Saturday' $week[7] = 'Sunday' end if $ARGS[0] = 'init_monthends': monthsend[1] = 31 if ((year mod 4 = 0) and (year mod 100 ! 0)) or (year mod 400 = 0): monthsend[2] = 29 else monthsend[2] = 28 end monthsend[3] = 31 monthsend[4] = 30 monthsend[5] = 31 monthsend[6] = 30 monthsend[7] = 31 monthsend[8] = 31 monthsend[9] = 30 monthsend[10] = 31 monthsend[11] = 30 monthsend[12] = 31 end !!=====================================================================================!! !! !! !! CLEANUP !! !! !! !!=====================================================================================!! if mid($ARGS[0], 1, 2) ! 'to': killvar 'dateVars' --- time ---------------------------------