MCPcopy Create free account
hub / github.com/ZDoom/Raze / UNSAFE_CCMD

Function UNSAFE_CCMD

source/common/engine/date.cpp:52–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50//==========================================================================
51
52UNSAFE_CCMD(setdate)
53{
54 if (argv.argc() != 3)
55 {
56 Printf("setdate HH:MM:SS DD-MM-YYYY: Set the current date\n");
57 return;
58 }
59
60 time_t today;
61 time(&today);
62 struct tm* timeinfo = localtime(&today);
63 if (timeinfo != nullptr)
64 {
65 auto clock = FString(argv[1]).Split(":");
66 auto date = FString(argv[2]).Split("-");
67 if(clock.Size() != 3 || date.Size() != 3)
68 {
69 Printf("setdate HH:MM:SS DD-MM-YYYY: Set the current date\n");
70 return;
71 }
72
73 if(!clock[0].IsInt())
74 {
75 Printf("Invalid hour\n");
76 return;
77 }
78 if (!clock[1].IsInt())
79 {
80 Printf("Invalid minutes\n");
81 return;
82 }
83 if (!clock[2].IsInt())
84 {
85 Printf("Invalid seconds\n");
86 return;
87 }
88 if (!date[0].IsInt())
89 {
90 Printf("Invalid day\n");
91 return;
92 }
93 if (!date[1].IsInt())
94 {
95 Printf("Invalid month\n");
96 return;
97 }
98 if (!date[2].IsInt())
99 {
100 Printf("Invalid year\n");
101 return;
102 }
103
104 //Set Date
105 timeinfo->tm_hour = int( clock[0].ToLong() );
106 timeinfo->tm_min = int( clock[1].ToLong() );
107 timeinfo->tm_sec = int( clock[2].ToLong() );
108 timeinfo->tm_mday = int( date[0].ToLong() );
109 timeinfo->tm_mon = int( date[1].ToLong() - 1); // Month interally is 0 - 11

Callers

nothing calls this directly

Calls 7

PrintfFunction · 0.85
argcMethod · 0.80
SplitMethod · 0.80
IsIntMethod · 0.80
ToLongMethod · 0.80
FStringClass · 0.50
SizeMethod · 0.45

Tested by

no test coverage detected