4 Global dayo(13) As Integer
5 Global mnth(12) As String
6 Const FordConstant = 18032'/* 5 hours 32 seconds, 5 hours is GMT, 32 seconds, I have no idea. */
8 Sub humantime (ByVal l&, mo%, da%, yr%, h%, m%, s%)
9 ' here art, pass it l the unix time number, and it'll return the others
10 Dim lm&, lh&, ld&, ll&
14 l = l - FordConstant ' account for GMT
19 lh = Int(l / 60) ' was lm
27 lm = Int((l + 365) / 365)
28 lm = Int(lm / 4)'; /* leap days */
30 '/* l is now whole days left */
31 yr = Int((l - lm) / 365)
34 If (yr Mod 4) = 0 Then
40 ld = Int((l - lm) / 365)
41 da = ((l - ld * 365) - lm) + 1
43 '/* da is days in this year */
45 For lm = 1 To 12 ' was 0
46 If (leap And lm > 1) Then
59 If (leap) And (mo > 2) Then
60 da = da - (dayo(mo - 1) + 1)
62 da = da - dayo(mo - 1)
100 Function strtime (t As Long) As String
101 'given a unixtime make a good string out of it
112 Call humantime(t, xmo, xda, xyr, xh, xm, xs)
113 s = mnth(xmo) + " " + Trim$(Str$(xda)) + ", " + Trim$(Str$(xyr))
120 If xh = 0 Then xh = 12
121 tm$ = Trim$(Str$(xm))
122 If (xm < 10) Then tm$ = "0" + tm$
123 s = s + " " + Trim$(Str$(xh)) + ":" + tm$ + ap
127 Function unixtime (mo%, da%, yr%, hr%, min%, sec%) As Long
128 'art, this is the other way, pass it month, day year ..., and it
129 'returns the long int
132 Dim ret As Long, first As Long, retl As Long
135 '/* leap year is divisible by four except every 4 hunred years, don't worry about it
136 ' we'll just die in year 2000, it happens to be divisible by 400 */
138 If (yr Mod 4 = 0) Then
139 leap = 1'; /* leap a bit wrong 12/31/88 to 1/1/89 */
143 first = first + ((yr2 + 1) \ 4)
145 first = first + dayo(mo - 1)' /* add up days in this year so far */
146 If ((leap = 1) And (mo > 2)) Then
150 first = first + da'; /* add the days in this month */
151 first = first - 1';/* don't count today's seconds */
153 '/* first is number of days go to seconds */
156 ret = ret * first'; /* number of seconds from 1970 to last nite */
160 ret = ret + (60 * min)
162 ret = ret + FordConstant'; /* I have no idea */