Skip to content

Instantly share code, notes, and snippets.

@schas002
Last active August 7, 2017 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schas002/87c17713d0dfde095f6c977b84917438 to your computer and use it in GitHub Desktop.
Save schas002/87c17713d0dfde095f6c977b84917438 to your computer and use it in GitHub Desktop.
A Felisian time converter.

feltime

A Felisian time converter.

Install

Put feltime.py on the Python module path.

Usage

import feltime
feltime.to_feltime(1234567890) # => (6011, 792, 819, 90.0)
# For reference, the POSIX epoch:
feltime.to_feltime(0) # => (6010, 558, 251, 200.0)

CLI

# run feltime without any arguments to show the current feltime:
$ feltime.py
6012-060:255:500 # for example
# pass a POSIX timestamp to convert it to feltime:
$ feltime.py 1234567890
6011-792:819:090

The Felisian what?

Felisians are the kind of alien furries featured in the dreamable space simulator Noctis. Briefly, Felisian time is counted in epocs, which are one billion Earth seconds each, and triads that subdivide the epocs: triad dexter, one million seconds, triad medius, one thousand seconds, and triad sinister.

API

Convert to Felisian time. Returns a tuple with the divisions, in order, the epoc, triad dexter, triad medius and triad sinister (with subseconds, if any).

Maintainer

License

MIT © Andrew Zyabin

#!/usr/bin/env python3
import math
EPOC6011 = 441748800 # timestamp
def to_feltime(timestamp):
'''Convert to Felisian time. Returns a tuple with the divisions, in order,
the epoc, triad dexter, triad medius and triad sinister (with subseconds,
if any).'''
since_epoc6011 = timestamp - EPOC6011
epocs = since_epoc6011 / 1e9
full_epocs = math.floor(epocs)
secs_since_epoc = (epocs - full_epocs) * 1e9
return (full_epocs + 6011, math.floor(secs_since_epoc % 1e9 / 1e6),
math.floor(secs_since_epoc % 1e6 / 1e3), secs_since_epoc % 1e3)
if __name__ == '__main__':
import argparse, textwrap, time
parser = argparse.ArgumentParser(description='Convert to Felisian time.',
epilog=textwrap.dedent('''
If TIME is omitted, convert current time. Authored by
@zyabin101@botsin.space.
'''))
parser.add_argument('time', nargs='?', default=time.time(), type=float,
help='the POSIX timestamp to convert', metavar='TIME')
args = parser.parse_args()
epoc, dexter, medius, sinister = to_feltime(args.time)
print('{0}-{1:0>3}:{2:0>3}:{3:0>3}'.format(epoc, dexter, medius,
math.floor(sinister)))
MIT License
Copyright (c) 2017-2017 Andrew Zyabin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment