Skip to main content

The French Republican calendar and decimal time in Python

Project description

Repcal

A small application that converts date and time to the systems used by the French First Republic.

The calendar from 1793 to 1805 and decimal time for about a year between 1794 and 1795. More information can be found on Wikipedia.

It uses the Romme method of calculating leap years, as in keeping the ones used by the French Republic and using the Gregorian rules for the years after the calendar was abolished.

CLI Tool

Installation using pipx:

$ pipx install repcal

When called without any parameters it will print the current local time and date:

$ repcal
7:76:5 - Septidi 7 nivôse an CCXXXII

Conversions

-i DATE, --input DATE

This parameter accepts a specific date and/or time in ISO format and will print it's republican counterpart.

$ repcal -i '1969-07-20 20:17:40'
8:45:60 - Primidi 1 thermidor an CLXXVII

UTC Offset

-u OFFSET, --utc-offset OFFSET

This parameter is used to get the current date and time for a given number of standard minutes from UTC. For example, the current time in New York (EST, UTC-05:00):

$ repcal -u -300

Paris Mean Time

-p, --paris-mean

For the full republican experience, it can also use Paris Mean Time (6.49 decimal minutes ahead of UTC).

Output Formatting

-f [FORMAT], --format [FORMAT]

The default output format can be overridden with a string containing placeholders for specific datetime values.

$ repcal -i '1969-07-20' -f '{%d} {%+B}'
1 Thermidor

Using -f, --format without a provided format string will print a cheat sheet of available placeholders.

The format can also be set using the environment variables REPCAL_DATE_FORMAT and REPCAL_TIME_FORMAT:

$ REPCAL_DATE_FORMAT='{%d} {%+B}' repcal -i '1969-07-20'

Python Package

The script can also installed with pip and used as a package in other Python projects:

from repcal import RepublicanDate, DecimalTime
from datetime import datetime

n = datetime.fromisoformat('1969-07-20 20:17:40')
rd = RepublicanDate.from_gregorian(n.date())
dt = DecimalTime.from_standard_time(n.time())

# The objects have standard string representations,...
print(rd) # Primidi 1 thermidor an CLXXVII
print(dt) # 8:45:60

# ...access to specific properties...
print(rd.get_year_roman()) # CLXXVII
print(dt.decimal) # 0,8456

# ...and formatting.
print(rd.get_formatter().format('{%d} {%+B}')) # 1 Thermidor

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

repcal-2.0.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

repcal-2.0.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file repcal-2.0.0.tar.gz.

File metadata

  • Download URL: repcal-2.0.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for repcal-2.0.0.tar.gz
Algorithm Hash digest
SHA256 aaca8ebe8249b8df30b12d980e64a477e2eabd15d287b317837560bb615ac2f8
MD5 d6eda609163af2470926eafceec82cdd
BLAKE2b-256 97422051ea249cee409f3cb85d87a4fde1a28f8bc7ba6c8ff6c33955ae353c4f

See more details on using hashes here.

File details

Details for the file repcal-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: repcal-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for repcal-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 44bbeb42c83edcd4d42d0cc7a1a73a426413bcf131247d275e0a8c891d59a70e
MD5 c93c923b3b11b7106873e35bed8282ba
BLAKE2b-256 c2d58680cc858e672b21c70672fbeb170d4185a5bc7524f58150266c1fe12580

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page