[Turn off line numbering]
1: arg time, @reftime;
2: var times, words, x, ctime, mnths, month, year, days, out, lt, rrk;
3:
4: // most of this was stolen from MOO (und ve are evil)
5: if (time < 1)
6: return "0 seconds";
7: [(reftime ?= time())] = reftime;
8: words = ["year", "month", "day", "hour", "minute", "second"];
9: times = [];
10: for x in ([60, 60, 24]) {
11: times = [time % x, @times];
12: time = time / x;
13: }
14: mnths = 0;
15: lt = localtime(reftime);
16: month = lt[6];
17: if (lt[7] < 100)
18: year = 1900 + lt[7];
19: else
20: year = lt[7];
21: days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
22: while (time >= days + (month == 2 && year % 4 == 0 && !(year % 400 in [100, 200, 300]))) {
23: refresh();
24: time -= days;
25: mnths++;
26: month++;
27: if (month > 12) {
28: year++;
29: month = 1;
30: }
31: }
32: times = [mnths / 12, mnths % 12, time, @times];
33: out = [];
34: for x in [1 .. 6] {
35: if (times[x] > 0)
36: out += [times[x] + " " + words[x] + (times[x] == 1 ? "" : "s")];
37: }
38: return out.to_english();
39:
40: // $#Edited: 01 Jul 97 14:04 $brandon
41: // $#Edited: 20 Feb 98 08:19 $user_bruce
["// Created 26-Mar-1995 as a part of ColdCore, see: @help Credit"]