#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include <syscall.h>
Go to the source code of this file.
|
| static const char * | dayOfWeek [7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" } |
| |
| static const char * | months [12] |
| |
◆ TZ_OFFSET_SECS
◆ asctime()
| char * asctime |
( |
const struct tm * |
tm | ) |
|
Definition at line 64 of file time.c.
65{
68}
char * asctime_r(const struct tm *tm, char *buf)
◆ asctime_r()
| char * asctime_r |
( |
const struct tm * |
tm, |
|
|
char * |
buf |
|
) |
| |
Definition at line 50 of file time.c.
51{
52
53
54
59
61}
static const char * months[12]
static const char * dayOfWeek[7]
int snprintf(char *str, size_t size, const char *fmt,...) __printflike(3
◆ ctime()
| char * ctime |
( |
const time_t * |
timep | ) |
|
Definition at line 78 of file time.c.
79{
81}
struct tm * localtime(const time_t *timep)
char * asctime(const struct tm *tm)
◆ ctime_r()
| char * ctime_r |
( |
const time_t * |
timep, |
|
|
char * |
buf |
|
) |
| |
Definition at line 71 of file time.c.
72{
75}
struct tm * localtime_r(const time_t *timep, struct tm *result)
◆ gettimeofday()
Definition at line 32 of file time.c.
33{
35
36 tv->
tv_sec = nsec / 1000000000;
37 tv->
tv_usec = (nsec % 1000000000) / 1000;
38
39 return 0;
40}
◆ gmtime()
| struct tm * gmtime |
( |
const time_t * |
timep | ) |
|
Definition at line 164 of file time.c.
165{
168}
struct tm * gmtime_r(const time_t *timep, struct tm *tm)
◆ gmtime_r()
| struct tm * gmtime_r |
( |
const time_t * |
timep, |
|
|
struct tm * |
tm |
|
) |
| |
Definition at line 108 of file time.c.
109{
113
114
115 secs = *timep % (60 * 60 * 24);
116 days = *timep / (60 * 60 * 24);
117 mins = secs / 60;
118 secs = secs % 60;
119
120
121 hours = mins / 60;
122 mins = mins % 60;
123
124
125 hours = hours % 24;
126
130
132
133 for (y = 1970; ; y++) {
136 daysOfYear = 366;
137 } else {
138 daysOfYear = 365;
139 }
140
141 if (days < daysOfYear) {
144 break;
145 }
146 days -= daysOfYear;
147 }
148
149 for (m = 0; ; m++) {
151
152 if (days < daysOfMonth) {
155 break;
156 }
157 days -= daysOfMonth;
158 }
159
161}
static int Time_DaysInMonth(uint64_t year, uint64_t month)
static bool Time_IsLeapYear(uint64_t year)
◆ localtime()
| struct tm * localtime |
( |
const time_t * |
timep | ) |
|
◆ localtime_r()
| struct tm * localtime_r |
( |
const time_t * |
timep, |
|
|
struct tm * |
result |
|
) |
| |
◆ mktime()
Definition at line 185 of file time.c.
186{
190
191
194 days += 366;
195 else
196 days += 365;
197 }
198
202 }
204 days += yday;
205
209
211
212 return secs;
213}
◆ settimeofday()
◆ time()
Definition at line 20 of file time.c.
21{
23 time_t sec = nsec / 1000000000;
24
25 if (t)
26 *t = sec;
27
28 return sec;
29}
◆ Time_DaysInMonth()
Definition at line 96 of file time.c.
97{
98 static const uint64_t days[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
99
101 return 29;
102 else
103 return days[month];
104}
◆ Time_IsLeapYear()
Definition at line 84 of file time.c.
85{
86 if ((year % 4) != 0)
87 return false;
88 if ((year % 100) != 0)
89 return true;
90 if ((year % 400) != 0)
91 return false;
92 return true;
93}
◆ dayOfWeek
| const char* dayOfWeek[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" } |
|
static |
◆ months
Initial value:= {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
}
Definition at line 14 of file time.c.