xboxscene.org forums

Author Topic: Date And Time Adjuster  (Read 1167 times)

flattspott

  • Archived User
  • Hero Member
  • *
  • Posts: 1220
Date And Time Adjuster
« on: September 05, 2004, 06:40:00 PM »

CODE
MinimumBuild 1230
Set OptionIndex 0
Set BaseYear 2004

SetFunc Temp Left 1 $TM_Month$
If %Temp% == 0 Then
   SetFunc MonthIndex Right 1 $TM_Month$
Else
   Set MonthIndex $TM_Month$
EndIf

Set YearIndex $tm_year$
Set DayIndex $TM_Day$
Set HourIndex $TM_Hours$
Set MinuteIndex $TM_Minutes$
Set SecondIndex $TM_Seconds$

Gosub MonthHandler
Gosub GetDay


:Loop
SetFunc Input IQPeekMsgID
If %Input% != "" Gosub InputHandler
Gosub MonthHandler
Gosub GetDay
Gosub OptionHandler
Gosub Draw
Goto Loop

:GetDay
SetFunc Temp Right 2 %YearIndex%
Set Temp2 %(Temp/4)%
Set YearCode %(Temp+Temp2)%
Set DayCode %(YearCode+MonthCode+DayIndex)%
:Repeater
If# %DayCode% > 7 Then
   Sub DayCode 7
   Goto Repeater
EndIf
If# %DayCode% <= 0 Then
   Add DayCode 7
EndIf
Gosub NameOfDay
Return

:NameOfDay
Switch %DayCode%
   Case 1
 Set DayName Monday
   EndCase
   Case 2
 Set DayName Tuesday
   EndCase
   Case 3
 Set DayName Wednesday
   EndCase
   Case 4
 Set DayName Thursday
   EndCase
   Case 5
 Set DayName Friday
   EndCase
   Case 6
 Set DayName Saturday
   EndCase
   Case 7
 Set DayName Sunday
   EndCase
EndSwitch
Return

:MonthHandler
Switch %MonthIndex%
   Case 1
 Set MonthCode 6
 Set MonthName January
 Set DaysInMonth 30
   EndCase
   Case 2
 Set MonthCode 2
 Set MonthName February
 Set Temp $TM_Year$
 FDiv Temp 4
 If %ToCheck% #^ "." Then
    Set DaysInMonth 28
 Else
    Set DaysInMonth 29
 EndIf
   EndCase
   Case 3
 Set MonthCode 2
 Set MonthName March
 Set DaysInMonth 31
   EndCase
   Case 4
 Set MonthCode 5
 Set MonthName April
 Set DaysInMonth 30
   EndCase
   Case 5
 Set MonthCode 0
 Set MonthName May
 Set DaysInMonth 31
   EndCase
   Case 6
 Set MonthCode 3
 Set MonthName June
 Set DaysInMonth 30
   EndCase
   Case 7
 Set MonthCode 5
 Set MonthName July
 Set DaysInMonth 31
   EndCase
   Case 8
 Set MonthCode 1
 Set MonthName August
 Set DaysInMonth 31
   EndCase
   Case 9
 Set MonthCode 4
 Set MonthName September
 Set DaysInMonth 30
   EndCase
   Case 10
 Set MonthCode 6
 Set MonthName October
 Set DaysInMonth 31
   EndCase
   Case 11
 Set MonthCode 2
 Set MonthName November
 Set DaysInMonth 30
   EndCase
   Case 12
 Set MonthCode 4
 Set MonthName December
 Set DaysInMonth 31
   EndCase
EndSwitch
Return

:Draw
BeginDraw
Box 0 0 640 480 0x%($rand%99)%0000%($rand%99)% 0x%($rand%99)%0000%($rand%99)%
Box 100 100 440 280 Black Black
   Text 320 120 Center "Date And Time Adjuster" White
   Text 320 150 Center "%DayName% $tm_time$" White
   Text 320 200 Center "%Option0%" White
   Text 320 220 Center "%Option1%" White
   Text 320 240 Center "%Option2%" White
   Text 320 260 Center "%Option3%" White
   Text 320 280 Center "%Option4%" White
   Text 320 335 Center "Press A to save to system" White
EndDraw
Return

:InputHandler
IQWaitMsg Any
If %MSG_ID% == "UI_BACK" Then
   Quit
EndIf
If %MSG_ID% == "UI_SELECT" Then
   Goto SetDateAndTime
EndIf
If %MSG_ID% == "UI_DN" Then
   If# %OptionIndex% != 4 Then
 Add OptionIndex 1
 Gosub OptionHandler
   EndIf
EndIf
If %MSG_ID% == "UI_UP" Then
   If# %OptionIndex% != 0 Then
 Sub OptionIndex 1
 Gosub OptionHandler
   EndIf
EndIf
If %MSG_ID% == "UI_LF" Then
   Switch %OptionIndex%
 Case 0
    Sub MonthIndex 1
    Gosub MonthHandler
 EndCase
 Case 1
    If# %DayIndex% != 1 Then
   Sub DayIndex 1
    EndIf
 EndCase
 Case 2
    If# %YearIndex% != %BaseYear% Then
   Sub YearIndex 1
    EndIf
 EndCase
 Case 3
    If# %HourIndex% != 01 Then
   Sub HourIndex 1
    EndIf
 EndCase
 Case 4
    If# %MinuteIndex% != 01 Then
   Sub MinuteIndex 1
    EndIf
 EndCase
   EndSwitch
EndIf
If %MSG_ID% == "UI_RT" Then
   Switch %OptionIndex%
 Case 0
    Add MonthIndex 1
    Gosub MonthHandler
 EndCase
 Case 1
    If# %DayIndex% != %DaysInMonth% Then
   Add DayIndex 1
    EndIf
 EndCase
 Case 2
    Add YearIndex 1
 EndCase
 Case 3
    If# %HourIndex% != 24 Then
   Add HourIndex 1
    EndIf
 EndCase
 Case 4
    If# %MinuteIndex% != 59 Then
   Add MinuteIndex 1
    EndIf
 EndCase
   EndSwitch
EndIf
Return

:OptionHandler
Gosub Option%OptionIndex%
Return

:Option0
Switch %MonthIndex%
   Case 1
 Set Option0 "Month : %MonthName% $GT$"
 Set Option1 "Day : %DayIndex%"
 Set Option2 "Year : %YearIndex%"
 Set Option3 "Hour : %HourIndex%"
 Set Option4 "Minutes : %MinuteIndex%"
   EndCase
   Case 12
 Set Option0 "Month : $LT$ %MonthName%"
 Set Option1 "Day : %DayIndex%"
 Set Option2 "Year : %YearIndex%"
 Set Option3 "Hour : %HourIndex%"
 Set Option4 "Minutes : %MinuteIndex%"
   EndCase
   Default
 Set Option0 "Month : $LT$ %MonthName% $GT$"
 Set Option1 "Day : %DayIndex%"
 Set Option2 "Year : %YearIndex%"
 Set Option3 "Hour : %HourIndex%"
 Set Option4 "Minutes : %MinuteIndex%"
   EndCase
EndSwitch
Return

:Option1
Switch %DayIndex%
   Case 1
 Set Option0 "Month : %MonthName%"
 Set Option1 "Day : %DayIndex% $GT$"
 Set Option2 "Year : %YearIndex%"
 Set Option3 "Hour : %HourIndex%"
 Set Option4 "Minutes : %MinuteIndex%"
   EndCase
   Case %DaysInMonth%
 Set Option0 "Month : %MonthName%"
 Set Option1 "Day : $LT$ %DayIndex%"
 Set Option2 "Year : %YearIndex%"
 Set Option3 "Hour : %HourIndex%"
 Set Option4 "Minutes : %MinuteIndex%"
   EndCase
   Default
 Set Option0 "Month : %MonthName%"
 Set Option1 "Day : $LT$ %DayIndex% $GT$"
 Set Option2 "Year : %YearIndex%"
 Set Option3 "Hour : %HourIndex%"
 Set Option4 "Minutes : %MinuteIndex%"
   EndCase
EndSwitch
Return

:Option2
Switch %YearIndex%
   Case 2004
 Set Option0 "Month : %MonthName%"
 Set Option1 "Day : %DayIndex%"
 Set Option2 "Year : %YearIndex% $GT$"
 Set Option3 "Hour : %HourIndex%"
 Set Option4 "Minutes : %MinuteIndex%"
   EndCase
   Default
 Set Option0 "Month : %MonthName%"
 Set Option1 "Day : %DayIndex%"
 Set Option2 "Year : $LT$ %YearIndex% $GT$"
 Set Option3 "Hour : %HourIndex%"
 Set Option4 "Minutes : %MinuteIndex%"
   EndCase
EndSwitch
Return

:Option3
Switch %HourIndex%
   Case 1
 Set Option0 "Month : %MonthName%"
 Set Option1 "Day : %DayIndex%"
 Set Option2 "Year : %YearIndex%"
 Set Option3 "Hour : %HourIndex% $GT$"
 Set Option4 "Minutes : %MinuteIndex%"
   EndCase
   Case 24
 Set Option0 "Month : %MonthName%"
 Set Option1 "Day : %DayIndex%"
 Set Option2 "Year : %YearIndex%"
 Set Option3 "Hour : $LT$ %HourIndex%"
 Set Option4 "Minutes : %MinuteIndex%"
   EndCase
   Default
 Set Option0 "Month : %MonthName%"
 Set Option1 "Day : %DayIndex%"
 Set Option2 "Year : %YearIndex%"
 Set Option3 "Hour : $LT$ %HourIndex% $GT$"
 Set Option4 "Minutes : %MinuteIndex%"
   EndCase
EndSwitch
Return

:Option4
Switch %MinuteIndex%
   Case 0
 Set Option0 "Month : %MonthName%"
 Set Option1 "Day : %DayIndex%"
 Set Option2 "Year : %YearIndex%"
 Set Option3 "Hour : %HourIndex%"
 Set Option4 "Minutes : %MinuteIndex% $GT$"
   EndCase
   Case 59
 Set Option0 "Month : %MonthName%"
 Set Option1 "Day : %DayIndex%"
 Set Option2 "Year : %YearIndex%"
 Set Option3 "Hour : %HourIndex%"
 Set Option4 "Minutes : $LT$ %MinuteIndex%"
   EndCase
   Default
 Set Option0 "Month : %MonthName%"
 Set Option1 "Day : %DayIndex%"
 Set Option2 "Year : %YearIndex%"
 Set Option3 "Hour : %HourIndex%"
 Set Option4 "Minutes : $LT$ %MinuteIndex% $GT$"
   EndCase
EndSwitch
Return

:SetDateAndTime
//   Date
SetFunc Temp Length %DayIndex%
If# %Temp% == 1 Then
   Set Day 0%DayIndex%
Else
   Set Day %DayIndex%
EndIf
SetFunc Temp Length %MonthIndex%
If# %Temp% == 1 Then
   Set Month 0%MonthIndex%
Else
   Set Month %MonthIndex%
EndIf
Set Year %YearIndex%
//   Time
SetFunc Temp Length %HourIndex%
If# %Temp% == 1 Then
   Set Hour 0%HourIndex%
Else
   Set Hour %HourIndex%
EndIf
SetFunc Temp Length %MinuteIndex%
If# %Temp% == 1 Then
   Set Minute 0%MinuteIndex%
Else
   Set Minute %MinuteIndex%
EndIf
Date %Day% %Month% %Year%
Time %Hour%:%Minute%
Quit
 <
Logged