Skip to content

Render the current time in your Emacs mode line using emoji / Chinese characters

License

Notifications You must be signed in to change notification settings

camdez/cn-zodiac-time.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chinese Zodiac Time for Emacs

Introduction

This library renders times via emoji / Chinese characters of the zodiac animals, primarily for displaying the current time on the Emacs mode line:

./screenshot.jpg

It’s a toy, not a serious calendar implementation—if that wasn’t clear from the cartoon animals. 🦁

Background

The method used to indicate the time is loosely based on a system used to measure time in the Ming dynasty which divided the day into 12 equal periods (時), named after the 12 earthly branches (地支). Because the animals of the Chinese zodiac map 1-to-1 with the earthly branches, it is equally possible to indicate the time with the animals (though I’m not suggesting this was traditionally done):

BranchAnimalTime 1 (hh)Time 2 (hh)
子 (zǐ)rat23–0100–02
丑 (chǒu)ox01–0302–04
寅 (yín)tiger03–0504–06
卯 (mǎo)hare05–0706–08
辰 (chén)dragon07–0908–10
巳 (sì)snake09–1110–12
午 (wǔ)horse11–1312–14
未 (wèi)sheep13–1514–16
申 (shēn)monkey15–1716–18
酉 (yǒu)cock17–1918–20
戌 (xū)dog19–2120–22
亥 (hài)pig21–2322–00

Time 1: used in ancient China until the Tang dynasty, and in ancient / medieval Japan.

Time 2: used in the Song dynasty of China.

(Table adapted from Units of Time in Ancient China and Japan by Mitsuru Sôma, /et. al./.)

This library uses the older Time 1 system. Notice that the first 時 spans midnight.

Given that each ancient 時 corresponds to two of our modern hours, it’s convenient for us to know whether we’re in the first or second half of that period for alignment with our own system of timekeeping.

Indeed, by the end of the Tang dynasty, there was already such a convention, appending either 「初」 or 「正」 to mark the first or second halves, respectively, of the time period. For example, 「子初」 indicated the period from 23-00, and 「子正」indicated 00-01.

While I have used that convention in this library with the earthly branches, I was uncertain how well it would read when paired with the animals of the zodiac (perhaps a native speaker can weigh in with an opinion here). I considered a few different options and ultimately settled on prefixing 「小」 and 「大」(small and large) to differentiate the animal-named periods, which I find quite charming:

Time‘cute‘traditional‘branches
3:00小🐯小虎寅初
4:00大🐯大虎寅正

If you’d prefer a different method, it is trivial to choose your own strings for both the 時 and for differentiating their halves (or not).

Basic Usage

The simplest way to use the library is by calling cn-zodiac-time, which renders the current time according to predefined styles.

The following two invocations are equivalent:

(cn-zodiac-time)
(cn-zodiac-time 'cute)
"大🐶 二十八分"

Formatting Styles

The full set of possible styles is:

cute大🐲 四十二分Animal face emoji (where available)
emoji大🐉 四十二分Animal emoji
traditional大龍 四十二分Animal names in traditional characters
simplified大龙 四十二分Animal names in simplified characters
branches辰正 四十二分Earthly branches

Displaying on the Mode Line

You can add the current formatted time to the mode line with:

(setq display-time-string-forms '((cn-zodiac-time 'cute)))

(Note the embedded style symbol.)

The mode line may not immediately update. To force an update, call:

(display-time-update)

If you’d like to make the mode line larger, you can use:

(set-face-attribute 'mode-line nil :height 200)

Advanced Formatting

If you’d like more control of the formatting, you can use cn-zodiac-format-time and provide your own set of (12) 2-hour (時) indicators, and well as the indicators to differentiate the first and seconds halves of the hour.

Status

Not very mature but appears to be working.

Installation

Download cn-zodiac-time.el to a directory on your Emacs load-path and call (require 'cn-zodiac-time).

Alternately, put it anywhere and call (load-file "/your/path/cn-zodiac-time.el").

Documentation

You’re looking at it.

Testing

This project does not currently have a test suite.

Contributing

GitHub issues and PRs are welcome. As a silly project, I may not process these things quickly, but I’ll get to them eventually.

License

Copyright © Cameron Desautels, 2024

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

About

Render the current time in your Emacs mode line using emoji / Chinese characters

Resources

License

Stars

Watchers

Forks