2021-07-03 05:07:57 +01:00
<!DOCTYPE HTML>
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html;charset=US-ASCII" >
2021-08-02 21:40:05 +01:00
< meta name = "generator" content = "ZealOS V0.13" >
2021-07-03 05:07:57 +01:00
< style type = "text/css" >
2021-07-29 03:20:15 +01:00
body {background-color:#fef1f0;}
.cF0{color:#000000;background-color:#fef1f0;}
.cF1{color:#0148a4;background-color:#fef1f0;}
.cF2{color:#3b7901;background-color:#fef1f0;}
.cF3{color:#057c7e;background-color:#fef1f0;}
.cF4{color:#bb2020;background-color:#fef1f0;}
.cF5{color:#9e42ae;background-color:#fef1f0;}
.cF6{color:#b57901;background-color:#fef1f0;}
.cF7{color:#b2b6af;background-color:#fef1f0;}
.cF8{color:#555753;background-color:#fef1f0;}
.cF9{color:#678fbb;background-color:#fef1f0;}
.cFA{color:#82bc49;background-color:#fef1f0;}
.cFB{color:#0097a2;background-color:#fef1f0;}
.cFC{color:#e26a6a;background-color:#fef1f0;}
.cFD{color:#c671bc;background-color:#fef1f0;}
.cFE{color:#c7ab00;background-color:#fef1f0;}
.cFF{color:#fef1f0;background-color:#fef1f0;}
2021-07-03 05:07:57 +01:00
< / style >
< / head >
< body >
2021-07-05 01:12:38 +01:00
< pre style = "font-family:monospace;font-size:12pt" >
2021-07-26 20:29:49 +01:00
< a name = "l1" > < / a > < span class = cF2 > //See < / span > < a href = "https://zeal-operating-system.github.io/ZealOS/Doc/TimeDate.DD.html#l1" > < span class = cF4 > ::/Doc/TimeDate.DD< / span > < / a > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l2" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l3" > < / a > < / span > < span class = cF9 > U16< / span > < span class = cF0 > < / span > < span class = cFB > month_start_days< / span > < span class = cF0 > [< / span > < span class = cFE > 12< / span > < span class = cF0 > ] = {< / span > < span class = cFE > 0< / span > < span class = cF0 > , < / span > < span class = cFE > 31< / span > < span class = cF0 > , < / span > < span class = cFE > 59< / span > < span class = cF0 > , < / span > < span class = cFE > 90< / span > < span class = cF0 > , < / span > < span class = cFE > 120< / span > < span class = cF0 > , < / span > < span class = cFE > 151< / span > < span class = cF0 > , < / span > < span class = cFE > 181< / span > < span class = cF0 > , < / span > < span class = cFE > 212< / span > < span class = cF0 > , < / span > < span class = cFE > 243< / span > < span class = cF0 > , < / span > < span class = cFE > 273< / span > < span class = cF0 > , < / span > < span class = cFE > 304< / span > < span class = cF0 > , < / span > < span class = cFE > 334< / span > < span class = cF0 > };
2021-07-03 05:07:57 +01:00
< a name = "l4" > < / a > < / span > < span class = cF9 > U16< / span > < span class = cF0 > < / span > < span class = cFB > month_start_days_leap< / span > < span class = cF0 > [< / span > < span class = cFE > 12< / span > < span class = cF0 > ] = {< / span > < span class = cFE > 0< / span > < span class = cF0 > , < / span > < span class = cFE > 31< / span > < span class = cF0 > , < / span > < span class = cFE > 60< / span > < span class = cF0 > , < / span > < span class = cFE > 91< / span > < span class = cF0 > , < / span > < span class = cFE > 121< / span > < span class = cF0 > , < / span > < span class = cFE > 152< / span > < span class = cF0 > , < / span > < span class = cFE > 182< / span > < span class = cF0 > , < / span > < span class = cFE > 213< / span > < span class = cF0 > , < / span > < span class = cFE > 244< / span > < span class = cF0 > , < / span > < span class = cFE > 274< / span > < span class = cF0 > , < / span > < span class = cFE > 305< / span > < span class = cF0 > , < / span > < span class = cFE > 335< / span > < span class = cF0 > };
< a name = "l5" > < / a >
< a name = "l6" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > < / span > < span class = cF5 > YearStartDate< / span > < span class = cF0 > (< / span > < span class = cF9 > I64< / span > < span class = cF0 > year)
< a name = "l7" > < / a > {< / span > < span class = cF2 > //32-bit day since AD 0, given year number.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l8" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > y1 = year - < / span > < span class = cFE > 1< / span > < span class = cF0 > , yd4000 = y1 / < / span > < span class = cFE > 4000< / span > < span class = cF0 > , yd400 = y1 / < / span > < span class = cFE > 400< / span > < span class = cF0 > , yd100 = y1 / < / span > < span class = cFE > 100< / span > < span class = cF0 > , yd4 = y1 / < / span > < span class = cFE > 4< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l9" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l10" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > year * < / span > < span class = cFE > 365< / span > < span class = cF0 > + yd4 - yd100 + yd400 - yd4000;
2021-07-03 05:07:57 +01:00
< a name = "l11" > < / a > }
< a name = "l12" > < / a >
< a name = "l13" > < / a > < / span > < span class = cF9 > CDate< / span > < span class = cF0 > < / span > < span class = cF5 > Struct2Date< / span > < span class = cF0 > (< / span > < span class = cF9 > CDateStruct< / span > < span class = cF0 > *_ds)
< a name = "l14" > < / a > {< / span > < span class = cF2 > //Convert CDateStruct to CDate.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l15" > < / a > < / span > < span class = cF9 > CDate< / span > < span class = cF0 > cdt;
< a name = "l16" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > i1, i2;
2021-07-03 05:07:57 +01:00
< a name = "l17" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l18" > < / a > i1 = < / span > < span class = cF5 > YearStartDate< / span > < span class = cF0 > (_ds-> year);
< a name = "l19" > < / a > i2 = < / span > < span class = cF5 > YearStartDate< / span > < span class = cF0 > (_ds-> year + < / span > < span class = cFE > 1< / span > < span class = cF0 > );
< a name = "l20" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (i2 - i1 == < / span > < span class = cFE > 365< / span > < span class = cF0 > )
< a name = "l21" > < / a > i1 += < / span > < span class = cFB > month_start_days< / span > < span class = cF0 > [_ds-> mon - < / span > < span class = cFE > 1< / span > < span class = cF0 > ];
< a name = "l22" > < / a > < / span > < span class = cF1 > else< / span > < span class = cF0 >
< a name = "l23" > < / a > i1 += < / span > < span class = cFB > month_start_days_leap< / span > < span class = cF0 > [_ds-> mon - < / span > < span class = cFE > 1< / span > < span class = cF0 > ];
< a name = "l24" > < / a > cdt.date = i1 + _ds-> day_of_mon - < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l25" > < / a > cdt.time = (_ds-> sec10000 + < / span > < span class = cFE > 100< / span > < span class = cF0 > * < / span > < span class = cF7 > (< / span > < span class = cF0 > _ds-> sec100 + < / span > < span class = cFE > 100< / span > < span class = cF0 > * (_ds-> sec + < / span > < span class = cFE > 60< / span > < span class = cF0 > * < / span > < span class = cF7 > (< / span > < span class = cF0 > _ds-> min + < / span > < span class = cFE > 60< / span > < span class = cF0 > * _ds-> hour< / span > < span class = cF7 > )< / span > < span class = cF0 > )< / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l26" > < / a > < < < / span > < span class = cFE > 21< / span > < span class = cF0 > / (< / span > < span class = cFE > 15< / span > < span class = cF0 > * < / span > < span class = cFE > 15< / span > < span class = cF0 > * < / span > < span class = cFE > 3< / span > < span class = cF0 > * < / span > < span class = cFE > 625< / span > < span class = cF0 > );
< a name = "l27" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > cdt;
2021-07-03 05:07:57 +01:00
< a name = "l28" > < / a > }
< a name = "l29" > < / a >
< a name = "l30" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > < / span > < span class = cF5 > DayOfWeek< / span > < span class = cF0 > (< / span > < span class = cF9 > I64< / span > < span class = cF0 > i)
< a name = "l31" > < / a > {< / span > < span class = cF2 > //Day of week, given 32-bit day since AD 0.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l32" > < / a > i += < / span > < span class = cF3 > CDATE_BASE_DAY_OF_WEEK< / span > < span class = cF0 > ;
< a name = "l33" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (i > = < / span > < span class = cFE > 0< / span > < span class = cF0 > )
< a name = "l34" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > i % < / span > < span class = cFE > 7< / span > < span class = cF0 > ;
< a name = "l35" > < / a > < / span > < span class = cF1 > else< / span > < span class = cF0 >
< a name = "l36" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > < / span > < span class = cFE > 6< / span > < span class = cF0 > - (< / span > < span class = cFE > 6< / span > < span class = cF0 > - i) % < / span > < span class = cFE > 7< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l37" > < / a > }
< a name = "l38" > < / a >
< a name = "l39" > < / a > < / span > < span class = cF1 > U0< / span > < span class = cF0 > < / span > < span class = cF5 > Date2Struct< / span > < span class = cF0 > (< / span > < span class = cF9 > CDateStruct< / span > < span class = cF0 > *_ds, < / span > < span class = cF9 > CDate< / span > < span class = cF0 > cdt)
< a name = "l40" > < / a > {< / span > < span class = cF2 > //Convert CDate to CDateStruct.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l41" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > i, k, date = cdt.date;
2021-07-03 05:07:57 +01:00
< a name = "l42" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l43" > < / a > _ds-> day_of_week = < / span > < span class = cF5 > DayOfWeek< / span > < span class = cF0 > (date);
< a name = "l44" > < / a > _ds-> year = (date + < / span > < span class = cFE > 1< / span > < span class = cF0 > ) * < / span > < span class = cFE > 100000< / span > < span class = cF0 > / < / span > < span class = cF3 > CDATE_YEAR_DAYS_INT< / span > < span class = cF0 > ;
< a name = "l45" > < / a > i = < / span > < span class = cF5 > YearStartDate< / span > < span class = cF0 > (_ds-> year);
2021-07-03 05:07:57 +01:00
< a name = "l46" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l47" > < / a > < / span > < span class = cF1 > while< / span > < span class = cF0 > (i > date)
< a name = "l48" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l49" > < / a > _ds-> year--;
< a name = "l50" > < / a > i = < / span > < span class = cF5 > YearStartDate< / span > < span class = cF0 > (_ds-> year);
< a name = "l51" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l52" > < / a > date -= i;
< a name = "l53" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (< / span > < span class = cF5 > YearStartDate< / span > < span class = cF7 > (< / span > < span class = cF0 > _ds-> year + < / span > < span class = cFE > 1< / span > < span class = cF7 > )< / span > < span class = cF0 > - i == < / span > < span class = cFE > 365< / span > < span class = cF0 > )
< a name = "l54" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l55" > < / a > k = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
< a name = "l56" > < / a > < / span > < span class = cF1 > while< / span > < span class = cF0 > (date > = < / span > < span class = cFB > month_start_days< / span > < span class = cF0 > [k + < / span > < span class = cFE > 1< / span > < span class = cF0 > ] & & k < < / span > < span class = cFE > 11< / span > < span class = cF0 > )
< a name = "l57" > < / a > k++;
< a name = "l58" > < / a > date -= < / span > < span class = cFB > month_start_days< / span > < span class = cF0 > [k];
< a name = "l59" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l60" > < / a > < / span > < span class = cF1 > else< / span > < span class = cF0 >
< a name = "l61" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l62" > < / a > k = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
< a name = "l63" > < / a > < / span > < span class = cF1 > while< / span > < span class = cF0 > (date > = < / span > < span class = cFB > month_start_days_leap< / span > < span class = cF0 > [k + < / span > < span class = cFE > 1< / span > < span class = cF0 > ] & & k < < / span > < span class = cFE > 11< / span > < span class = cF0 > )
< a name = "l64" > < / a > k++;
< a name = "l65" > < / a > date -= < / span > < span class = cFB > month_start_days_leap< / span > < span class = cF0 > [k];
< a name = "l66" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l67" > < / a > _ds-> mon = k + < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l68" > < / a > _ds-> day_of_mon = date + < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l69" > < / a > k = (< / span > < span class = cFE > 625< / span > < span class = cF0 > * < / span > < span class = cFE > 15< / span > < span class = cF0 > * < / span > < span class = cFE > 15< / span > < span class = cF0 > * < / span > < span class = cFE > 3< / span > < span class = cF0 > * cdt.time) > > < / span > < span class = cFE > 21< / span > < span class = cF0 > + < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l70" > < / a > _ds-> sec10000 = < / span > < span class = cF5 > ModU64< / span > < span class = cF0 > (& k, < / span > < span class = cFE > 100< / span > < span class = cF0 > );
< a name = "l71" > < / a > _ds-> sec100 = < / span > < span class = cF5 > ModU64< / span > < span class = cF0 > (& k, < / span > < span class = cFE > 100< / span > < span class = cF0 > );
< a name = "l72" > < / a > _ds-> sec = < / span > < span class = cF5 > ModU64< / span > < span class = cF0 > (& k, < / span > < span class = cFE > 60< / span > < span class = cF0 > );
< a name = "l73" > < / a > _ds-> min = < / span > < span class = cF5 > ModU64< / span > < span class = cF0 > (& k, < / span > < span class = cFE > 60< / span > < span class = cF0 > );
< a name = "l74" > < / a > _ds-> hour = k;
2021-07-03 05:07:57 +01:00
< a name = "l75" > < / a > }
< a name = "l76" > < / a >
< a name = "l77" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > < / span > < span class = cF5 > FirstDayOfMon< / span > < span class = cF0 > (< / span > < span class = cF9 > I64< / span > < span class = cF0 > i)
< a name = "l78" > < / a > {< / span > < span class = cF2 > //First day of month, given 32-bit day since AD 0.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l79" > < / a > < / span > < span class = cF9 > CDateStruct< / span > < span class = cF0 > ds;
< a name = "l80" > < / a > < / span > < span class = cF9 > CDate< / span > < span class = cF0 > cdt = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l81" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l82" > < / a > cdt.date = i;
< a name = "l83" > < / a > < / span > < span class = cF5 > Date2Struct< / span > < span class = cF0 > (& ds, cdt);
< a name = "l84" > < / a > ds.day_of_mon = < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l85" > < / a > cdt = < / span > < span class = cF5 > Struct2Date< / span > < span class = cF0 > (& ds);
2021-07-03 05:07:57 +01:00
< a name = "l86" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l87" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > cdt.date;
2021-07-03 05:07:57 +01:00
< a name = "l88" > < / a > }
< a name = "l89" > < / a >
< a name = "l90" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > < / span > < span class = cF5 > LastDayOfMon< / span > < span class = cF0 > (< / span > < span class = cF9 > I64< / span > < span class = cF0 > i)
< a name = "l91" > < / a > {< / span > < span class = cF2 > //Last day of month, given 32-bit day since AD 0.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l92" > < / a > < / span > < span class = cF9 > CDateStruct< / span > < span class = cF0 > ds;
< a name = "l93" > < / a > < / span > < span class = cF9 > CDate< / span > < span class = cF0 > cdt = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l94" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l95" > < / a > cdt.date = i;
< a name = "l96" > < / a > < / span > < span class = cF5 > Date2Struct< / span > < span class = cF0 > (& ds, cdt);
< a name = "l97" > < / a > ds.mon++;
< a name = "l98" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (ds.mon == < / span > < span class = cFE > 13< / span > < span class = cF0 > )
< a name = "l99" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l100" > < / a > ds.mon = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
< a name = "l101" > < / a > ds.year++;
< a name = "l102" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l103" > < / a > ds.day_of_mon = < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l104" > < / a > cdt = < / span > < span class = cF5 > Struct2Date< / span > < span class = cF0 > (& ds);
2021-07-03 05:07:57 +01:00
< a name = "l105" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l106" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > cdt.date - < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l107" > < / a > }
< a name = "l108" > < / a >
< a name = "l109" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > < / span > < span class = cF5 > FirstDayOfYear< / span > < span class = cF0 > (< / span > < span class = cF9 > I64< / span > < span class = cF0 > i)
< a name = "l110" > < / a > {< / span > < span class = cF2 > //First day of year, given 32-bit day since AD 0.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l111" > < / a > < / span > < span class = cF9 > CDateStruct< / span > < span class = cF0 > ds;
< a name = "l112" > < / a > < / span > < span class = cF9 > CDate< / span > < span class = cF0 > cdt = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l113" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l114" > < / a > cdt.date = i;
< a name = "l115" > < / a > < / span > < span class = cF5 > Date2Struct< / span > < span class = cF0 > (& ds, cdt);
< a name = "l116" > < / a > ds.day_of_mon = < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l117" > < / a > ds.mon = < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l118" > < / a > cdt = < / span > < span class = cF5 > Struct2Date< / span > < span class = cF0 > (& ds);
2021-07-03 05:07:57 +01:00
< a name = "l119" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l120" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > cdt.date;
2021-07-03 05:07:57 +01:00
< a name = "l121" > < / a > }
< a name = "l122" > < / a >
< a name = "l123" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > < / span > < span class = cF5 > LastDayOfYear< / span > < span class = cF0 > (< / span > < span class = cF9 > I64< / span > < span class = cF0 > i)
< a name = "l124" > < / a > {< / span > < span class = cF2 > //Last day of year, given 32-bit day since AD 0.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l125" > < / a > < / span > < span class = cF9 > CDateStruct< / span > < span class = cF0 > ds;
< a name = "l126" > < / a > < / span > < span class = cF9 > CDate< / span > < span class = cF0 > cdt = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l127" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l128" > < / a > cdt.date = i;
< a name = "l129" > < / a > < / span > < span class = cF5 > Date2Struct< / span > < span class = cF0 > (& ds, cdt);
< a name = "l130" > < / a > ds.day_of_mon = < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l131" > < / a > ds.mon = < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l132" > < / a > ds.year++;
< a name = "l133" > < / a > cdt = < / span > < span class = cF5 > Struct2Date< / span > < span class = cF0 > (& ds);
2021-07-03 05:07:57 +01:00
< a name = "l134" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l135" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > cdt.date - < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l136" > < / a > }
< a name = "l137" > < / a >
< a name = "l138" > < / a > < / span > < span class = cF1 > U8< / span > < span class = cF0 > < / span > < span class = cF5 > CMOSRegRead< / span > < span class = cF0 > (< / span > < span class = cF9 > I64< / span > < span class = cF0 > register)
2021-07-26 20:29:49 +01:00
< a name = "l139" > < / a > {< / span > < span class = cF2 > //Read val from CMOS register. See < / span > < a href = "https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l191" > < span class = cF4 > CMOS Registers< / span > < / a > < span class = cF2 > .< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l140" > < / a > < / span > < span class = cF5 > OutU8< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOS_SEL< / span > < span class = cF0 > , register);
2021-07-03 05:07:57 +01:00
< a name = "l141" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l142" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > < / span > < span class = cF5 > InU8< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOS_DATA< / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l143" > < / a > }
< a name = "l144" > < / a >
< a name = "l145" > < / a > < / span > < span class = cF1 > U0< / span > < span class = cF0 > < / span > < span class = cF5 > CMOSRegWrite< / span > < span class = cF0 > (< / span > < span class = cF9 > I64< / span > < span class = cF0 > register, < / span > < span class = cF9 > I64< / span > < span class = cF0 > val)
2021-07-26 20:29:49 +01:00
< a name = "l146" > < / a > {< / span > < span class = cF2 > //Write val to CMOS register. See < / span > < a href = "https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l191" > < span class = cF4 > CMOS Registers< / span > < / a > < span class = cF2 > .< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l147" > < / a > < / span > < span class = cF5 > OutU8< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOS_SEL< / span > < span class = cF0 > , register);
< a name = "l148" > < / a > < / span > < span class = cF5 > OutU8< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOS_DATA< / span > < span class = cF0 > , val);
2021-07-03 05:07:57 +01:00
< a name = "l149" > < / a > }
< a name = "l150" > < / a >
< a name = "l151" > < / a > < / span > < span class = cF1 > Bool< / span > < span class = cF0 > < / span > < span class = cF5 > CMOSIsBcd< / span > < span class = cF0 > ()
< a name = "l152" > < / a > {< / span > < span class = cF2 > //Check of CMOS is in binary-coded decimal mode.< / span > < span class = cF0 >
2021-07-26 20:29:49 +01:00
< a name = "l153" > < / a > < / span > < span class = cF2 > // Ex: 15:32:44 == 0x15:0x32:0x44 (not good). We use < / span > < a href = "https://zeal-operating-system.github.io/ZealOS/Kernel/KDate.CC.html#l157" > < span class = cF4 > Bcd2Binary< / span > < / a > < span class = cF2 > () to convert.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l154" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > !(< / span > < span class = cF5 > CMOSRegRead< / span > < span class = cF7 > (< / span > < span class = cF3 > CMOSR_STATUS_B< / span > < span class = cF7 > )< / span > < span class = cF0 > & < / span > < span class = cF3 > CMOSF_BINARY< / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l155" > < / a > }
< a name = "l156" > < / a >
< a name = "l157" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > < / span > < span class = cFD > Bcd2Binary< / span > < span class = cF0 > (< / span > < span class = cF9 > U64< / span > < span class = cF0 > b)
< a name = "l158" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l159" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > i, res = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l160" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l161" > < / a > < / span > < span class = cF1 > for< / span > < span class = cF0 > (i = < / span > < span class = cFE > 0< / span > < span class = cF0 > ; i < < / span > < span class = cFE > 16< / span > < span class = cF0 > ; i++)
< a name = "l162" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l163" > < / a > res = res * < / span > < span class = cFE > 10< / span > < span class = cF0 > + b > > < / span > < span class = cFE > 60< / span > < span class = cF0 > ;
< a name = "l164" > < / a > b < < = < / span > < span class = cFE > 4< / span > < span class = cF0 > ;
< a name = "l165" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l166" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l167" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > res;
2021-07-03 05:07:57 +01:00
< a name = "l168" > < / a > }
< a name = "l169" > < / a >
< a name = "l170" > < / a > < / span > < span class = cF1 > U0< / span > < span class = cF0 > < / span > < span class = cFD > NowDateTimeStruct< / span > < span class = cF0 > (< / span > < span class = cF9 > CDateStruct< / span > < span class = cF0 > *_ds)
< a name = "l171" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l172" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > i;
< a name = "l173" > < / a > < / span > < span class = cF1 > U8< / span > < span class = cF0 > *b = _ds;
2021-07-03 05:07:57 +01:00
< a name = "l174" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l175" > < / a > < / span > < span class = cF5 > MemSet< / span > < span class = cF0 > (_ds, < / span > < span class = cFE > 0< / span > < span class = cF0 > , < / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF9 > CDateStruct< / span > < span class = cF7 > )< / span > < span class = cF0 > );
< a name = "l176" > < / a > < / span > < span class = cF1 > PUSHFD< / span > < span class = cF0 >
< a name = "l177" > < / a > < / span > < span class = cF1 > CLI< / span > < span class = cF0 >
< a name = "l178" > < / a > < / span > < span class = cF1 > while< / span > < span class = cF0 > (< / span > < span class = cF5 > LBts< / span > < span class = cF7 > (< / span > < span class = cF0 > & < / span > < span class = cFB > sys_semas< / span > < span class = cF0 > [< / span > < span class = cF3 > SEMA_SYS_DATE< / span > < span class = cF0 > ], < / span > < span class = cFE > 0< / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l179" > < / a > < / span > < span class = cF1 > PAUSE< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l180" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l181" > < / a > < / span > < span class = cF1 > do< / span > < span class = cF0 >
< a name = "l182" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l183" > < / a > < / span > < span class = cF1 > while< / span > < span class = cF0 > (< / span > < span class = cF5 > CMOSRegRead< / span > < span class = cF7 > (< / span > < span class = cF3 > CMOSR_STATUS_A< / span > < span class = cF7 > )< / span > < span class = cF0 > & < / span > < span class = cF3 > CMOSF_UPDATING< / span > < span class = cF0 > )
< a name = "l184" > < / a > < / span > < span class = cF1 > PAUSE< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l185" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l186" > < / a > b[< / span > < span class = cFE > 2< / span > < span class = cF0 > ] = < / span > < span class = cF5 > CMOSRegRead< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOSR_SEC< / span > < span class = cF0 > );
< a name = "l187" > < / a > b[< / span > < span class = cFE > 3< / span > < span class = cF0 > ] = < / span > < span class = cF5 > CMOSRegRead< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOSR_MIN< / span > < span class = cF0 > );
< a name = "l188" > < / a > b[< / span > < span class = cFE > 4< / span > < span class = cF0 > ] = < / span > < span class = cF5 > CMOSRegRead< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOSR_HOUR< / span > < span class = cF0 > );
< a name = "l189" > < / a > b[< / span > < span class = cFE > 5< / span > < span class = cF0 > ] = < / span > < span class = cF5 > CMOSRegRead< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOSR_DAY_OF_WEEK< / span > < span class = cF0 > );
< a name = "l190" > < / a > b[< / span > < span class = cFE > 6< / span > < span class = cF0 > ] = < / span > < span class = cF5 > CMOSRegRead< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOSR_DAY_OF_MONTH< / span > < span class = cF0 > );
< a name = "l191" > < / a > b[< / span > < span class = cFE > 7< / span > < span class = cF0 > ] = < / span > < span class = cF5 > CMOSRegRead< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOSR_MONTH< / span > < span class = cF0 > );
< a name = "l192" > < / a > b[< / span > < span class = cFE > 8< / span > < span class = cF0 > ] = < / span > < span class = cF5 > CMOSRegRead< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOSR_YEAR< / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l193" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l194" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l195" > < / a > < / span > < span class = cF1 > while< / span > < span class = cF0 > (< / span > < span class = cF5 > CMOSRegRead< / span > < span class = cF7 > (< / span > < span class = cF3 > CMOSR_STATUS_A< / span > < span class = cF7 > )< / span > < span class = cF0 > & < / span > < span class = cF3 > CMOSF_UPDATING< / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l196" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l197" > < / a > < / span > < span class = cF5 > LBtr< / span > < span class = cF0 > (& < / span > < span class = cFB > sys_semas< / span > < span class = cF0 > [< / span > < span class = cF3 > SEMA_SYS_DATE< / span > < span class = cF0 > ], < / span > < span class = cFE > 0< / span > < span class = cF0 > );
< a name = "l198" > < / a > < / span > < span class = cF1 > POPFD< / span > < span class = cF0 >
< a name = "l199" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (< / span > < span class = cF5 > CMOSIsBcd< / span > < span class = cF0 > )
< a name = "l200" > < / a > < / span > < span class = cF1 > for< / span > < span class = cF0 > (i = < / span > < span class = cFE > 2< / span > < span class = cF0 > ; i < < / span > < span class = cFE > 9< / span > < span class = cF0 > ; i++)
< a name = "l201" > < / a > b[i] = < / span > < span class = cFD > Bcd2Binary< / span > < span class = cF0 > (b[i]);
2021-07-03 05:07:57 +01:00
< a name = "l202" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l203" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (_ds-> year > < / span > < span class = cFE > 255< / span > < span class = cF0 > ) _ds-> year = < / span > < span class = cFE > 255< / span > < span class = cF0 > ;
< a name = "l204" > < / a > _ds-> year += < / span > < span class = cFE > 2000< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l205" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l206" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (_ds-> mon > < / span > < span class = cFE > 12< / span > < span class = cF0 > ) _ds-> mon = < / span > < span class = cFE > 12< / span > < span class = cF0 > ;
< a name = "l207" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (_ds-> day_of_mon > < / span > < span class = cFE > 31< / span > < span class = cF0 > ) _ds-> day_of_mon = < / span > < span class = cFE > 31< / span > < span class = cF0 > ;
< a name = "l208" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (_ds-> day_of_week > < / span > < span class = cFE > 6< / span > < span class = cF0 > ) _ds-> day_of_week = < / span > < span class = cFE > 6< / span > < span class = cF0 > ;
< a name = "l209" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (_ds-> hour > < / span > < span class = cFE > 23< / span > < span class = cF0 > ) _ds-> hour = < / span > < span class = cFE > 23< / span > < span class = cF0 > ;
< a name = "l210" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (_ds-> min > < / span > < span class = cFE > 59< / span > < span class = cF0 > ) _ds-> min = < / span > < span class = cFE > 59< / span > < span class = cF0 > ;
< a name = "l211" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (_ds-> sec > < / span > < span class = cFE > 59< / span > < span class = cF0 > ) _ds-> sec = < / span > < span class = cFE > 59< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l212" > < / a > }
< a name = "l213" > < / a >
< a name = "l214" > < / a > < / span > < span class = cF9 > CDate< / span > < span class = cF0 > < / span > < span class = cF5 > Now< / span > < span class = cF0 > ()
< a name = "l215" > < / a > {< / span > < span class = cF2 > //Current datetime.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l216" > < / a > < / span > < span class = cF9 > CDateStruct< / span > < span class = cF0 > ds;
2021-07-03 05:07:57 +01:00
< a name = "l217" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l218" > < / a > < / span > < span class = cFD > NowDateTimeStruct< / span > < span class = cF0 > (& ds);
< a name = "l219" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > < / span > < span class = cF5 > Struct2Date< / span > < span class = cF0 > (& ds)-< / span > < span class = cFB > local_time_offset< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l220" > < / a > }
< a name = "l221" > < / a >
< a name = "l222" > < / a > < / span > < span class = cF1 > U0< / span > < span class = cF0 > < / span > < span class = cF5 > TimeSet< / span > < span class = cF0 > (< / span > < span class = cF9 > CDateStruct< / span > < span class = cF0 > *ds)
2021-07-26 20:29:49 +01:00
< a name = "l223" > < / a > {< / span > < span class = cF2 > //Set CMOS time from user crafted < / span > < a href = "https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l216" > < span class = cF4 > CDateStruct< / span > < / a > < span class = cF2 > .< / span > < span class = cF0 >
< a name = "l224" > < / a > < / span > < span class = cF2 > //Make sure to use hex as decimals if BCD mode. Check using < / span > < a href = "https://zeal-operating-system.github.io/ZealOS/Kernel/KDate.CC.html#l151" > < span class = cF4 > CMOSIsBcd< / span > < / a > < span class = cF2 > ().< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l225" > < / a > < / span > < span class = cF2 > //Ex: if bcd mode and we want 12/30, 10:45:15 -- 0x12/0x30, 0x10:0x45:0x15.< / span > < span class = cF0 >
< a name = "l226" > < / a > < / span > < span class = cF2 > //Pass year as double digit number (obviously 20XX is too big for a U8).< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l227" > < / a > < / span > < span class = cF1 > U8< / span > < span class = cF0 > *b = ds;
2021-07-03 05:07:57 +01:00
< a name = "l228" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l229" > < / a > < / span > < span class = cF1 > PUSHFD< / span > < span class = cF0 >
< a name = "l230" > < / a > < / span > < span class = cF1 > CLI< / span > < span class = cF0 >
< a name = "l231" > < / a > < / span > < span class = cF1 > while< / span > < span class = cF0 > (< / span > < span class = cF5 > LBts< / span > < span class = cF7 > (< / span > < span class = cF0 > & < / span > < span class = cFB > sys_semas< / span > < span class = cF0 > [< / span > < span class = cF3 > SEMA_SYS_DATE< / span > < span class = cF0 > ], < / span > < span class = cFE > 0< / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l232" > < / a > < / span > < span class = cF1 > PAUSE< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l233" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l234" > < / a > < / span > < span class = cF1 > while< / span > < span class = cF0 > (< / span > < span class = cF5 > CMOSRegRead< / span > < span class = cF7 > (< / span > < span class = cF3 > CMOSR_STATUS_A< / span > < span class = cF7 > )< / span > < span class = cF0 > & < / span > < span class = cF3 > CMOSF_UPDATING< / span > < span class = cF0 > )
< a name = "l235" > < / a > < / span > < span class = cF1 > PAUSE< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l236" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l237" > < / a > < / span > < span class = cF5 > CMOSRegWrite< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOSR_SEC< / span > < span class = cF0 > , b[< / span > < span class = cFE > 2< / span > < span class = cF0 > ]);
< a name = "l238" > < / a > < / span > < span class = cF5 > CMOSRegWrite< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOSR_MIN< / span > < span class = cF0 > , b[< / span > < span class = cFE > 3< / span > < span class = cF0 > ]);
< a name = "l239" > < / a > < / span > < span class = cF5 > CMOSRegWrite< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOSR_HOUR< / span > < span class = cF0 > , b[< / span > < span class = cFE > 4< / span > < span class = cF0 > ]);
< a name = "l240" > < / a > < / span > < span class = cF5 > CMOSRegWrite< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOSR_DAY_OF_WEEK< / span > < span class = cF0 > , b[< / span > < span class = cFE > 5< / span > < span class = cF0 > ]);
< a name = "l241" > < / a > < / span > < span class = cF5 > CMOSRegWrite< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOSR_DAY_OF_MONTH< / span > < span class = cF0 > , b[< / span > < span class = cFE > 6< / span > < span class = cF0 > ]);
< a name = "l242" > < / a > < / span > < span class = cF5 > CMOSRegWrite< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOSR_MONTH< / span > < span class = cF0 > , b[< / span > < span class = cFE > 7< / span > < span class = cF0 > ]);
< a name = "l243" > < / a > < / span > < span class = cF5 > CMOSRegWrite< / span > < span class = cF0 > (< / span > < span class = cF3 > CMOSR_YEAR< / span > < span class = cF0 > , b[< / span > < span class = cFE > 8< / span > < span class = cF0 > ]);
2021-07-03 05:07:57 +01:00
< a name = "l244" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l245" > < / a > < / span > < span class = cF5 > LBtr< / span > < span class = cF0 > (& < / span > < span class = cFB > sys_semas< / span > < span class = cF0 > [< / span > < span class = cF3 > SEMA_SYS_DATE< / span > < span class = cF0 > ], < / span > < span class = cFE > 0< / span > < span class = cF0 > );
< a name = "l246" > < / a > < / span > < span class = cF1 > POPFD< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l247" > < / a > }
< / span > < / pre > < / body >
< / html >