Welcome, guest | Sign In | My Account | Store | Cart

This recipe emulates time from the fictional planet of Aens. The code is meant to be a novelty and not for real programming.

Python, 63 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'''Support module for Aens time conversion.

This module provides several functions that allow
conversion from earth seconds to Aens time units.'''

__version__ = 1.2

################################################################################

import time

def aens_seconds():
    'Return current Aens seconds.'
    return time.time() - 946684800

def aens_year(seconds):
    'Converts from seconds to years.'
    return int(seconds) / 29030400 + 1

def aens_season(seconds):
    'Converts from seconds to seasons.'
    return int(seconds) / 7257600 % 4 + 1

def aens_month(seconds):
    'Converts from seconds to months.'
    return int(seconds) / 2419200 % 3 + 1

def aens_week(seconds):
    'Converts from seconds to weeks.'
    return int(seconds) / 604800 % 4 + 1

def aens_day(seconds):
    'Converts from seconds to days.'
    return int(seconds) / 86400 % 7 + 1

def aens_alpha(seconds):
    'Converts from seconds to alphas.'
    return int(seconds % 86400 * 1000 / 86400)

def aens_beta(seconds):
    'Converts from seconds to betas.'
    return int(seconds % 86400 * 1000000 / 86400 % 1000)

def basic_format(seconds):
    'Converts from seconds to basic format.'
    return '.'.join((str(aens_year(seconds)), str(aens_season(seconds)), str(aens_month(seconds)), str(aens_week(seconds)), str(aens_day(seconds)), str(aens_alpha(seconds)).zfill(3), str(aens_beta(seconds)).zfill(3)))

def timer(seconds):
    'Prints time for specified number of seconds.'
    start = time.time()
    while time.time() - start <= seconds:
        print basic_format(aens_seconds())
        beta = aens_beta(aens_seconds())
        while beta == aens_beta(aens_seconds()):
            pass

################################################################################

if __name__ == '__main__':
    import sys
    print 'Content-Type: text/plain'
    print
    print file(sys.argv[0]).read()

A timer function is provided to visualize the passing of time on Aens. The most I've been able to do with this module is use it to encode timestamps.