1#include "shared.rsh"
2
3static bool basic_test(uint32_t index) {
4    bool failed = false;
5
6    rs_time_t curTime = rsTime(0);
7    rs_tm tm;
8    rsDebug("curTime", curTime);
9
10    rsLocaltime(&tm, &curTime);
11
12    rsDebug("tm.tm_sec", tm.tm_sec);
13    rsDebug("tm.tm_min", tm.tm_min);
14    rsDebug("tm.tm_hour", tm.tm_hour);
15    rsDebug("tm.tm_mday", tm.tm_mday);
16    rsDebug("tm.tm_mon", tm.tm_mon);
17    rsDebug("tm.tm_year", tm.tm_year);
18    rsDebug("tm.tm_wday", tm.tm_wday);
19    rsDebug("tm.tm_yday", tm.tm_yday);
20    rsDebug("tm.tm_isdst", tm.tm_isdst);
21
22    // Test a specific time (since we set America/Los_Angeles localtime)
23    curTime = 1294438893;
24    rsLocaltime(&tm, &curTime);
25
26    _RS_ASSERT(tm.tm_sec == 33);
27    _RS_ASSERT(tm.tm_min == 21);
28    _RS_ASSERT(tm.tm_hour == 14);
29    _RS_ASSERT(tm.tm_mday == 7);
30    _RS_ASSERT(tm.tm_mon == 0);
31    _RS_ASSERT(tm.tm_year == 111);
32    _RS_ASSERT(tm.tm_wday == 5);
33    _RS_ASSERT(tm.tm_yday == 6);
34    _RS_ASSERT(tm.tm_isdst == 0);
35
36    return failed;
37}
38
39void test_rstime(uint32_t index, int test_num) {
40    bool failed = false;
41    failed |= basic_test(index);
42
43    if (failed) {
44        rsSendToClientBlocking(RS_MSG_TEST_FAILED);
45        rsDebug("rstime_test FAILED", -1);
46    }
47    else {
48        rsSendToClientBlocking(RS_MSG_TEST_PASSED);
49        rsDebug("rstime_test PASSED", 0);
50    }
51}
52
53