1

The following setting display the date in Gregorian calendar in the mode line.

(setq display-time-day-and-date t)
(display-time)

My question is how to change the above settings for date to be shown in the Julian calendar?

1
  • 1
    Does the display-time-format variable help you?
    – giordano
    Commented Jan 14, 2015 at 14:34

1 Answer 1

2

You can compute arbitrary date strings by overriding display-time-string-forms.

The documentation says this:

List of expressions governing display of the time in the mode line. For most purposes, you can control the time format using `display-time-format' which is a more standard interface.

This expression is a list of expressions that can involve the keywords load, day, month, and year, 12-hours, 24-hours, minutes, seconds, all numbers in string form, and monthname, dayname, am-pm, and time-zone all alphabetic strings, and mail a true/nil value.

For example, the form

'((substring year -2) "/" month "/" day
  " " 24-hours ":" minutes ":" seconds
  (if time-zone " (") time-zone (if time-zone ")")
  (if mail " Mail" ""))

would give mode line times like `94/12/30 21:07:48 (UTC)'.

To display the Julian date as provided by calendar try this:

(require 'calendar)
(setq display-time-string-forms
      '((calendar-julian-date-string)))
(display-time)
4
  • by Julian date, I mean the default Julian date of Emacs. That can be given by M-x calendar then M-x calendar-julian-print-date.
    – Name
    Commented Jan 14, 2015 at 16:15
  • I'm not familiar with Julian dates, but please see my updated answer. You can use display-time-string-forms to call calendar-julian-date-string on the Gregorian date.
    – user2005
    Commented Jan 14, 2015 at 19:37
  • Thank you. (require 'calendar) should be added. By the way what is the value now. When restarting Emacs, the displaying time becomes different. I think without now it would be fine.
    – Name
    Commented Jan 14, 2015 at 21:00
  • now has the value of evaluating (current-time).
    – user2005
    Commented Jan 14, 2015 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.