@@ -20,6 +20,7 @@ CMOS::Time& CMOS::Time::hw_update() {
2020 // We're supposed to check this before every read
2121 while (update_in_progress ());
2222 const reg_t r_cent = x86::ACPI::get ().cmos_century ();
23+ int century = 0 ;
2324
2425 if (CMOS::mode_binary ()) {
2526 f.second = get (r_sec);
@@ -29,7 +30,7 @@ CMOS::Time& CMOS::Time::hw_update() {
2930 f.day_of_month = get (r_day);
3031 f.month = get (r_month);
3132 f.year = get (r_year);
32- f. century = get (r_cent);
33+ century = get (r_cent);
3334 } else {
3435 f.second = bcd_to_binary (get (r_sec));
3536 f.minute = bcd_to_binary (get (r_min));
@@ -38,7 +39,16 @@ CMOS::Time& CMOS::Time::hw_update() {
3839 f.day_of_month = bcd_to_binary (get (r_day));
3940 f.month = bcd_to_binary (get (r_month));
4041 f.year = bcd_to_binary (get (r_year));
41- f.century = bcd_to_binary (get (r_cent));
42+ century = bcd_to_binary (get (r_cent));
43+ }
44+
45+ // Insanity
46+ #define CURRENT_YEAR 2017 // Change this each year!
47+ if (century != 0 ) {
48+ f.year += century * 100 ;
49+ } else {
50+ f.year += (CURRENT_YEAR / 100 ) * 100 ;
51+ if (f.year < CURRENT_YEAR) f.year += 100 ;
4252 }
4353
4454 // Convert to 24-hour clock if necessary
@@ -53,9 +63,7 @@ CMOS::Time& CMOS::Time::hw_update() {
5363std::string CMOS::Time::to_string (){
5464 std::array<char ,20 > str;
5565 sprintf (str.data (), " %.2i-%.2i-%iT%.2i:%.2i:%.2iZ" ,
56- f.century * 100 + f.year ,
57- f.month ,
58- f.day_of_month ,
66+ f.year , f.month , f.day_of_month ,
5967 f.hour , f.minute , f.second );
6068 return std::string (str.data (), str.size ());
6169}
0 commit comments