How to Use
eralegis.js — Javascript helper library for rendering Era Legis dates
The purpose of this time service is to provide a relatively easy means of including the Thelemic date into HTML content as plain old text rather than images. Unlike images, text can be styled with CSS, flows more evenly with the surrounding content, and can be scaled and transformed in numerous ways.
To include the current Thelemic date, the simplest usage of this API is:
<span class="date93"></span>
...
<script src="https://eralegis.info/eralegis.js"></script>
The date93 class triggers the functionality. The element could be a <span>, <div>, <p>, or many other elements so long as they are assigned that class. The style of the date output as well as the time zone or using a date other than the present can be controlled by setting attributes to this element. This is best described with a few examples, the markup followed by the stylized output.
If you want to pull dates from an alternate API server instead of the date.eralegis.info host, set the window.eralegisBaseUrl value to that URL before loading the eralegis.js script.
(The 1.0 version of this library depended on jQuery being loaded. Version 2.0 and beyond have no dependencies and will work without jQuery.)
Examples
<span data-evdate="2012-12-09 05:35:00" class="date93"></span>
☉ in 17° Sagittarii : ☽ in 20° Librae : dies Solis : Anno ⅠⅤⅹⅹ æræ legis
<span data-evdate="2012-12-09 05:35:00" data-tz="US/Pacific" class="date93"></span>
☉ in 17° Sagittarii : ☽ in 20° Librae : dies Saturni : Anno ⅠⅤⅹⅹ æræ legis
<span data-evdate="2012-12-09 05:35:00" data-show-deg="0" class="date93"></span>
☉ in Sagittario : ☽ in Libra : dies Solis : Anno ⅠⅤⅹⅹ æræ legis
<span data-evdate="2012-12-09 05:35:00" data-lang="symbol" class="date93"></span>
☉ in 17° ♐ : ☽ in 20° ♎ : ☉ : ⅠⅤⅹⅹ
<span data-evdate="2012-12-09 05:35:00" class="date93" data-show-deg="0" data-show-dow="0" data-show-year="0" data-show-terse="1" data-lang="symbol"></span>
☉ ♐ : ☽ ♎
If the standard attribute flags don’t provide enough configurability, the output can be run through a custom template:
<span data-evdate="2012-12-09 05:35:00" class="date93" data-lang="english">Sol in {ssign}, Luna in {lsign}, {dow}</span>
Sol in Sagittarius, Luna in Libra, Sunday
<span data-evdate="2012-12-09 05:35:00" class="date93" data-lang="symbol">Our Lord and Father the Sun in {sdeg}° {ssign}, year {year1}:{year2}</span>
Our Lord and Father the Sun in 17° ♐, year ⅠⅤ:ⅹⅹ
The template variables are ssign, sdeg, lsign, ldeg, dow, year1, year2.
Attributes
General attributes:
data-evdate- A date or timestamp in ISO8601 format (e.g. YYYY-MM-DD HH:MM:SS). Defaults to now.
data-lang- One of latin (default), english, symbol, or poor-latin.
data-tz- Appropriate time zone values are TZ values from the IANA zoneinfo database (common list here). Only used for day-of-week calculation. Defaults to current time zone offset, as reported by the user’s browser.
data-location- Used to calculate sunrise time, which is in turn used to calculate the day-of-week value. Can be
autoto rely on the geolocation provided by the user’s browser or given lat/lon coordinates in the decimal form of45.5:-122.7. Sunrise defaults to 6am if no location is provided. data-roman-year- Render year values in Roman numerals. Defaults to 1. Set to 0 for Arabic.
Attributes which alter the default template:
data-show-terse- Render the “in” in “Sol in Pisces”. Defaults to 0.
data-show-deg- Render the numeric degree value and degree symbol. Defaults to 1.
data-show-dow- Render the day of the week. Defaults to 1.
data-show-year- Render the year. Defaults to 1.
Other notes
The server side of this service is a Rust application hosted on Fly.io.
Override the default EraLegis server URL by setting window.eralegisBaseUrl before loading the script.
Missing or garbled symbols in the rendered dates are almost certainly the result of the font in use having no sigils for the corresponding Unicode code points. In particular, fonts frequently lack the zodiacal symbols. If you run into this try using another font or possibly use CSS to switch to another font for just those characters. Suggestions for more elegant and robust solutions to this problem are welcome.
Era Legis CSS — dates without Javascript
If you can’t or would rather not run scripts on a page, the date can be delivered as a stylesheet instead. The server returns a CSS rule that writes the date into an element of your choosing, so it still flows with the surrounding text and takes on its font, size and colour. Request it by appending .css to the URI path or by adding format=css, and include it with a <link> tag:
<link rel="stylesheet" href="https://date.eralegis.info/now.css?tz=US/Pacific&id=today">
...
<p>Today is <span id="today"></span>.</p>
The stylesheet the server sends back for a specific date looks like this:
<link rel="stylesheet" href="https://date.eralegis.info/2012-12-09T05:35:00.css?tz=US/Pacific&id=today">
#today::after { content: "☉ in 17° Sagittarii : ☽ in 25° Librae : dies Saturni : Anno ⅠⅤⅹⅹ æræ legis"; }
The <link> tag can go in the page’s <body> if you can’t edit its <head>.
Choosing the element
id- The date is written into the element with this id. An id belongs to a single element, so use one
<link>per date. class- The date is written into every element with this class, so one stylesheet can fill in the same date in several places.
Give one or the other, not both. If neither is given, the class date93 is used. Names may contain letters, digits, - and _, and may not start with a digit.
To show different styles of date on one page, include a stylesheet for each, each with its own id or class:
<link rel="stylesheet" href="https://date.eralegis.info/now.css?tz=US/Pacific&id=full">
<link rel="stylesheet" href="https://date.eralegis.info/now.css?tz=US/Pacific&class=sym&lang=symbol&show-deg=0">
Parameters
The options are the same as the eralegis.js attributes above, with the data- prefix removed: tz, lang, location, roman-year, show-terse, show-deg, show-dow, show-year and template. The server also accepts underscores in place of the hyphens, as in show_deg. The date goes in the path, as in the example above; use now for the current date.
Without Javascript, the browser can’t tell the server where the reader is, so a few things work differently:
tzdefaults to UTC rather than the reader’s time zone. Set it to the time zone your readers are most likely in.location=autoisn’t available. Give coordinates such aslocation=45.5:-122.7, or leave it out to use the 6am default sunrise.- Browsers may keep the stylesheet for up to five minutes, so for a short while after sunrise, or after the Sun or Moon changes sign, a reader can see the previous date.
The text has a few limits that come from how CSS works. Readers can’t select or copy it, most browsers’ find-in-page won’t match it, and search engines don’t index it, though screen readers do read it aloud. A template produces plain text only, so markup such as a <span> inside the template isn’t possible.
As a fallback for eralegis.js
The two methods can be combined, so that readers with Javascript get the date in their own time zone and readers without it still see a date. Leave out id and class so the stylesheet targets the date93 elements, and add a rule that hides the stylesheet’s text once eralegis.js has filled in the element:
<link rel="stylesheet" href="https://date.eralegis.info/now.css?tz=US/Pacific">
<style>[data-eralegis-loaded]::after { content: none !important; }</style>
...
<span class="date93"></span>
...
<script src="https://eralegis.info/eralegis.js"></script>
This needs eralegis.js 3.1 or later, which marks each element it fills in with data-eralegis-loaded.
Era Legis Image Renderer
Instead of pulling the date as text, the solar date can also be rendered into a PNG image file for inclusion in HTML documents. The client indicates this by either specifying a format=png or appending .png to the URI path. The calling format will look something like:
<img src="https://date.eralegis.info/2018-12-10T12:34:56.png?tz=US/Pacific">
<img src="https://date.eralegis.info/now.png?lang=symbol">
<img src="https://date.eralegis.info/2018-12-10T12:34:56?format=png&tz=US/Pacific">
In addition to the parameters shown above for the eralegis.js library (with the data- prefix removed), these further parameters are available:
color- A three- or six-digit hexadecimal value.
font- One of
serif(default),sans,code, ormono. points- Numeric point size for the font.
Era Legis Date Picker
The front page of this site hosts a date picker tool that’s useful for quickly converting vulgar dates into solar ones. The Elm source for this tool is available on Gitlab.