183 lines
13 KiB
HTML
Executable File
183 lines
13 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="generator" content="TempleOS V5.03">
|
|
<meta name="viewport" content="width=device-width">
|
|
<link rel="stylesheet" href="/style/templeos.css">
|
|
<script src="/script/templeos.js"></script>
|
|
<style type="text/css">
|
|
.cF0{color:#000000;background-color:#ffffff;}
|
|
.cF1{color:#0000aa;background-color:#ffffff;}
|
|
.cF2{color:#00aa00;background-color:#ffffff;}
|
|
.cF3{color:#00aaaa;background-color:#ffffff;}
|
|
.cF4{color:#aa0000;background-color:#ffffff;}
|
|
.cF5{color:#aa00aa;background-color:#ffffff;}
|
|
.cF6{color:#aa5500;background-color:#ffffff;}
|
|
.cF7{color:#aaaaaa;background-color:#ffffff;}
|
|
.cF8{color:#555555;background-color:#ffffff;}
|
|
.cF9{color:#5555ff;background-color:#ffffff;}
|
|
.cFA{color:#55ff55;background-color:#ffffff;}
|
|
.cFB{color:#55ffff;background-color:#ffffff;}
|
|
.cFC{color:#ff5555;background-color:#ffffff;}
|
|
.cFD{color:#ff55ff;background-color:#ffffff;}
|
|
.cFE{color:#ffff55;background-color:#ffffff;}
|
|
.cFF{color:#ffffff;background-color:#ffffff;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre id="content">
|
|
<a name="l1"></a><span class=cF0>#</span><span class=cF1>define</span><span class=cF0> TIME_FILENAME </span><span class=cF6>"~/TimeClock/TimeFile.DATA.Z"</span><span class=cF0>
|
|
<a name="l2"></a>
|
|
<a name="l3"></a>#</span><span class=cF1>define</span><span class=cF0> TET_EOF 0
|
|
<a name="l4"></a>#</span><span class=cF1>define</span><span class=cF0> TET_PUNCH_IN 1
|
|
<a name="l5"></a>#</span><span class=cF1>define</span><span class=cF0> TET_PUNCH_OUT 2
|
|
<a name="l6"></a>
|
|
<a name="l7"></a></span><span class=cF1>class</span><span class=cF0> TimeEntry
|
|
<a name="l8"></a>{
|
|
<a name="l9"></a> TimeEntry *next,*last;
|
|
<a name="l10"></a> </span><span class=cF1>U8</span><span class=cF0> type;
|
|
<a name="l11"></a> </span><span class=cF9>CDate</span><span class=cF0> datetime;
|
|
<a name="l12"></a> </span><span class=cF1>U8</span><span class=cF0> *desc;
|
|
<a name="l13"></a>};
|
|
<a name="l14"></a>
|
|
<a name="l15"></a></span><span class=cF1>U0</span><span class=cF0> TimeFileRead(TimeEntry *header)
|
|
<a name="l16"></a>{
|
|
<a name="l17"></a> </span><span class=cF1>U8</span><span class=cF0> *buf,*ptr;
|
|
<a name="l18"></a> </span><span class=cF9>I64</span><span class=cF0> type;
|
|
<a name="l19"></a> TimeEntry *tmpt;
|
|
<a name="l20"></a> buf=</span><span class=cF5>FileRead</span><span class=cF0>(TIME_FILENAME);
|
|
<a name="l21"></a> </span><span class=cF1>if</span><span class=cF0> (!buf)
|
|
<a name="l22"></a> buf=</span><span class=cF5>CAlloc</span><span class=cF0>(1);
|
|
<a name="l23"></a> </span><span class=cF5>QueInit</span><span class=cF0>(header);
|
|
<a name="l24"></a> ptr=buf;
|
|
<a name="l25"></a> </span><span class=cF1>while</span><span class=cF0> (type=*ptr++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l26"></a> tmpt=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>TimeEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l27"></a> tmpt->type=type;
|
|
<a name="l28"></a> tmpt->datetime=*ptr(</span><span class=cF9>CDate</span><span class=cF0> *)++;
|
|
<a name="l29"></a> tmpt->desc=</span><span class=cF5>StrNew</span><span class=cF0>(ptr);
|
|
<a name="l30"></a> ptr+=</span><span class=cF5>StrLen</span><span class=cF0>(ptr)+1;
|
|
<a name="l31"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpt,header->last);
|
|
<a name="l32"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l33"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
|
<a name="l34"></a>}
|
|
<a name="l35"></a>
|
|
<a name="l36"></a></span><span class=cF1>U0</span><span class=cF0> TimeFileWrite(TimeEntry *header)
|
|
<a name="l37"></a>{
|
|
<a name="l38"></a> </span><span class=cF1>U8</span><span class=cF0> *buf,*ptr;
|
|
<a name="l39"></a> TimeEntry *tmpt;
|
|
<a name="l40"></a> </span><span class=cF9>I64</span><span class=cF0> size=1; </span><span class=cF2>//for EOF</span><span class=cF0>
|
|
<a name="l41"></a>
|
|
<a name="l42"></a> tmpt=header->next;
|
|
<a name="l43"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt!=header) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l44"></a> size+=</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0>)+</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CDate</span><span class=cF0>)+</span><span class=cF5>StrLen</span><span class=cF0>(tmpt->desc)+1;
|
|
<a name="l45"></a> tmpt=tmpt->next;
|
|
<a name="l46"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l47"></a> buf=</span><span class=cF5>MAlloc</span><span class=cF0>(size);
|
|
<a name="l48"></a>
|
|
<a name="l49"></a> ptr=buf;
|
|
<a name="l50"></a> tmpt=header->next;
|
|
<a name="l51"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt!=header) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l52"></a> *ptr++=tmpt->type;
|
|
<a name="l53"></a> *ptr(</span><span class=cF9>CDate</span><span class=cF0> *)++=tmpt->datetime;
|
|
<a name="l54"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(ptr,tmpt->desc);
|
|
<a name="l55"></a> ptr+=</span><span class=cF5>StrLen</span><span class=cF0>(tmpt->desc)+1;
|
|
<a name="l56"></a> tmpt=tmpt->next;
|
|
<a name="l57"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l58"></a> *ptr=TET_EOF;
|
|
<a name="l59"></a> </span><span class=cF5>FileWrite</span><span class=cF0>(TIME_FILENAME,buf,size);
|
|
<a name="l60"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
|
<a name="l61"></a>}
|
|
<a name="l62"></a>
|
|
<a name="l63"></a></span><span class=cF1>U0</span><span class=cF0> TimeEntriesDel(TimeEntry *header)
|
|
<a name="l64"></a>{
|
|
<a name="l65"></a> TimeEntry *tmpt=header->next,*tmpt1;
|
|
<a name="l66"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt!=header) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l67"></a> tmpt1=tmpt->next;
|
|
<a name="l68"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpt->desc);
|
|
<a name="l69"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpt);
|
|
<a name="l70"></a> tmpt=tmpt1;
|
|
<a name="l71"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l72"></a> </span><span class=cF5>Free</span><span class=cF0>(header);
|
|
<a name="l73"></a>}
|
|
<a name="l74"></a>
|
|
<a name="l75"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> TimeRep(TimeEntry **_header=</span><span class=cF3>NULL</span><span class=cF0>)
|
|
<a name="l76"></a>{
|
|
<a name="l77"></a> </span><span class=cF1>Bool</span><span class=cF0> is_in=</span><span class=cF3>FALSE</span><span class=cF0>,first=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l78"></a> </span><span class=cF9>I64</span><span class=cF0> week,cur_week=-1,week_total;
|
|
<a name="l79"></a> TimeEntry *tmpt,*header=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>TimeEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l80"></a> </span><span class=cF1>if</span><span class=cF0> (_header) *_header=header;
|
|
<a name="l81"></a> TimeFileRead(header);
|
|
<a name="l82"></a> tmpt=header->next;
|
|
<a name="l83"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt!=header) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l84"></a> week=tmpt->datetime.date/7; </span><span class=cF2>//TODO</span><span class=cF0>
|
|
<a name="l85"></a> </span><span class=cF1>if</span><span class=cF0> (week!=cur_week) {
|
|
<a name="l86"></a> </span><span class=cF1>if</span><span class=cF0> (!first) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l87"></a> </span><span class=cF1>if</span><span class=cF0> (is_in)
|
|
<a name="l88"></a> week_total+=</span><span class=cF5>Now</span><span class=cF0>;
|
|
<a name="l89"></a> </span><span class=cF6>"Week Total:%T\n"</span><span class=cF0>,week_total-</span><span class=cFB>local_time_offset</span><span class=cF0>;
|
|
<a name="l90"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l91"></a> first=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l92"></a> cur_week=week;
|
|
<a name="l93"></a> week_total=0;
|
|
<a name="l94"></a> }
|
|
<a name="l95"></a> </span><span class=cF1>if</span><span class=cF0> (tmpt->type==TET_PUNCH_IN) {
|
|
<a name="l96"></a> </span><span class=cF6>"$RED$IN "</span><span class=cF0>;
|
|
<a name="l97"></a> </span><span class=cF1>if</span><span class=cF0> (!is_in)
|
|
<a name="l98"></a> week_total-=tmpt->datetime;
|
|
<a name="l99"></a> is_in=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l100"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
|
<a name="l101"></a> </span><span class=cF6>"$RED$OUT"</span><span class=cF0>;
|
|
<a name="l102"></a> </span><span class=cF1>if</span><span class=cF0> (is_in)
|
|
<a name="l103"></a> week_total+=tmpt->datetime;
|
|
<a name="l104"></a> is_in=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l105"></a> }
|
|
<a name="l106"></a> </span><span class=cF6>" %D %T:$FG$\n%s\n"</span><span class=cF0>,tmpt->datetime,tmpt->datetime,tmpt->desc;
|
|
<a name="l107"></a> tmpt=tmpt->next;
|
|
<a name="l108"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l109"></a> </span><span class=cF1>if</span><span class=cF0> (is_in)
|
|
<a name="l110"></a> week_total+=</span><span class=cF5>Now</span><span class=cF0>;
|
|
<a name="l111"></a> </span><span class=cF6>"$RED$Week Total:%T$FG$\n"</span><span class=cF0>,week_total-</span><span class=cFB>local_time_offset</span><span class=cF0>;
|
|
<a name="l112"></a> </span><span class=cF1>if</span><span class=cF0> (!_header)
|
|
<a name="l113"></a> TimeEntriesDel(header);
|
|
<a name="l114"></a> </span><span class=cF1>return</span><span class=cF0> is_in;
|
|
<a name="l115"></a>}
|
|
<a name="l116"></a>
|
|
<a name="l117"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> PunchOut()
|
|
<a name="l118"></a>{
|
|
<a name="l119"></a> TimeEntry *tmpt,*header;
|
|
<a name="l120"></a> </span><span class=cF1>if</span><span class=cF0> (!TimeRep</span><span class=cF7>(</span><span class=cF0>&header</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l121"></a> </span><span class=cF6>"$BK,1$Already Punched-Out$BK,0$\n"</span><span class=cF0>;
|
|
<a name="l122"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l123"></a> tmpt=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>TimeEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l124"></a> tmpt->type=TET_PUNCH_OUT;
|
|
<a name="l125"></a> tmpt->datetime=</span><span class=cF5>Now</span><span class=cF0>;
|
|
<a name="l126"></a> </span><span class=cF6>"\nEnter Description.\nPress <ESC> when done.\n"</span><span class=cF0>;
|
|
<a name="l127"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>tmpt->desc=</span><span class=cF5>GetStr</span><span class=cF0>(,,</span><span class=cF3>GSF_WITH_NEW_LINE</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l128"></a> tmpt->desc=</span><span class=cF5>CAlloc</span><span class=cF0>(1);
|
|
<a name="l129"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpt,header->last);
|
|
<a name="l130"></a> TimeFileWrite(header);
|
|
<a name="l131"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l132"></a> TimeEntriesDel(header);
|
|
<a name="l133"></a>}
|
|
<a name="l134"></a>
|
|
<a name="l135"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> PunchIn()
|
|
<a name="l136"></a>{
|
|
<a name="l137"></a> TimeEntry *tmpt,*header;
|
|
<a name="l138"></a> </span><span class=cF1>if</span><span class=cF0> (TimeRep</span><span class=cF7>(</span><span class=cF0>&header</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l139"></a> </span><span class=cF6>"$BK,1$Already Punched-In$BK,0$\n"</span><span class=cF0>;
|
|
<a name="l140"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l141"></a> tmpt=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>TimeEntry</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l142"></a> tmpt->type=TET_PUNCH_IN;
|
|
<a name="l143"></a> tmpt->datetime=</span><span class=cF5>Now</span><span class=cF0>;
|
|
<a name="l144"></a> </span><span class=cF6>"\nEnter Description.\nPress <ESC> when done.\n"</span><span class=cF0>;
|
|
<a name="l145"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>tmpt->desc=</span><span class=cF5>GetStr</span><span class=cF0>(,,</span><span class=cF3>GSF_WITH_NEW_LINE</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l146"></a> tmpt->desc=</span><span class=cF5>CAlloc</span><span class=cF0>(1);
|
|
<a name="l147"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpt,header->last);
|
|
<a name="l148"></a> TimeFileWrite(header);
|
|
<a name="l149"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l150"></a> TimeEntriesDel(header);
|
|
<a name="l151"></a>}
|
|
</span></pre></body>
|
|
</html>
|