9#include <sys/kassert.h>
10#include <sys/kdebug.h>
12#include <sys/spinlock.h>
19static const char *
dayOfWeek[7] = {
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat" };
21 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
22 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
39 if ((year % 100) != 0)
41 if ((year % 400) != 0)
49 static const uint64_t days[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
67 for (m = 0; m <
tm->month; m++) {
83 for (y = 1970; y <
tm->year; y++) {
92 for (m = 0; m <
tm->month; m++) {
101 secs = 24 * days +
tm->hour;
102 secs = secs * 60 +
tm->min;
103 secs = secs * 60 +
tm->sec;
116 secs = epoch % (60 * 60 * 24);
117 days = epoch / (60 * 60 * 24);
132 tm->wday = (days + 3) % 7;
134 for (y = 1970; ; y++) {
142 if (days < daysOfYear) {
153 if (days < daysOfMonth) {
220 kprintf(
"%s %s %d %02d:%02d:%02d %04d\n",
224 kprintf(
"Epoch: %lu\n", epoch);
int kprintf(const char *fmt,...)
#define REGISTER_DBGCMD(_NAME, _DESC, _FUNC)
static Spinlock ktimeLock
static int KTimeDaysInMonth(uint64_t year, uint64_t month)
void KTime_GetTime(KTime *tm)
void KTime_FromEpoch(UnixEpoch epoch, KTime *tm)
static bool KTimeIsLeapYear(uint64_t year)
static uint64_t ktimeLastTSC
UnixEpochNS KTime_GetEpochNS()
void KTime_Fixup(KTime *tm)
static const char * months[12]
static uint64_t ktimeLastEpoch
static void Debug_Ticks()
static const char * dayOfWeek[7]
void KTime_SetTime(UnixEpoch epoch, uint64_t tsc, uint64_t tps)
UnixEpoch KTime_ToEpoch(const KTime *tm)
UnixEpoch KTime_GetEpoch()
void Spinlock_Unlock(Spinlock *lock) __UNLOCK_EX(*lock)
#define SPINLOCK_TYPE_NORMAL
void Spinlock_Lock(Spinlock *lock) __LOCK_EX(*lock)
void Spinlock_Init(Spinlock *lock, const char *name, uint64_t type)