/* kernel/time.c * * Copyright (C) 2021, 2022 intirain. * * This file is part of evx. * * evx is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * evx is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with evx. If not, see */ #include #include #include #include #include #include #include struct ktime kernel_startup_time; struct timezone timezone; int __init time_init(void) { timezone.utcplus = CONFIG_TIMEZONE; read_hw_clock(&kernel_startup_time); show_time(&kernel_startup_time); return 0; } void show_time(struct ktime *tm) { show_time_tz(tm, &timezone); } void show_time_tz(struct ktime *tts, struct timezone *tz) { struct ktime tm = *tts; tm.hour += tz->utcplus; if (tm.hour >= 24) { tm.hour -= 24; tm.day++; /* I said, I've no interest in doing these * BORING but necessary things. Just leave them here. */ } kmlog(KERN_INFO "%d-%d-%d %d:%d:%d (UTC %c%d)\n", tm.year, tm.month, tm.day, tm.hour, tm.min, tm.sec, tz->utcplus > 0 ? '+' : '-', tz->utcplus); } kernel_init(time_init);