-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathda-kalender.el
More file actions
executable file
·194 lines (162 loc) · 6.77 KB
/
Copy pathda-kalender.el
File metadata and controls
executable file
·194 lines (162 loc) · 6.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
;;; da-kalender.el --- Danish calendar for Emacs -*-coding:utf-8-*-
;; Copyright (c) 2018 Søren Lund <soren@lund.org>
;; Author: Søren Lund <soren@lund.org>
;; Version: 1.2
;; Keywords: calendar danish localization
;; This file is not part of GNU Emacs.
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Danish calendar localization. This is my version of the swedish
;; localization, sv-kalender.el, by Daniel Jensen - see
;; http://bigwalter.net/daniel/elisp/sv-kalender.el
;; This file will modify how Emacs displays its calendar. The names of
;; months, days, etc. have been replaced with danish
;; translations. Furthermore the default american holidays are
;; replaced by danish holidays.
;; To use it, save this file somewhere in your load-path and add (load
;; "da-kalender") to your ~/.emacs file.
;;; History
;; 1.0 - Initial release (Mar 25th, 2010)
;; 1.1 - Added week numbers (Feb 13th, 2014)
;; 1.2 - Fixed to work with newer version of Emacs (Sep 24th, 2018)
;;; Code:
;; Week starts on monday
(setq calendar-week-start-day 1)
;; Use european date style, i.e. date/month
(setq european-calendar-style 'european)
;; Date format
(setq calendar-date-display-form
'((if dayname
(concat dayname ", "))
day " " monthname " " year))
;; 24 hour clock format
(setq calendar-time-display-form
'(24-hours ":" minutes))
;; Weekday names
(setq calendar-day-name-array
["søndag" "mandag" "tirsdag" "onsdag" "torsdag" "fredag" "lørdag"])
(setq calendar-day-abbrev-array
["søn" "man" "tirs" "ons" "tors" "fre" "lør"])
(setq calendar-day-header-array
["sø" "ma" "ti" "on" "to" "fr" "lø"])
;; Month names
(setq calendar-month-name-array
["januar" "februar" "marts" "april" "maj" "juni"
"juli" "august" "september" "oktober" "november" "december"])
(setq calendar-month-abbrev-array
["jan" "feb" "mar" "apr" "maj" "jun" "jul" "aug" "sep" "okt" "nov" "dec"])
:; Equinoxes/solstices names
;; http://www.dmi.dk/dmi/nyd_aarets_laengste_dag_-_sommersolhverv
(eval-after-load "solar"
'(progn
(setq solar-n-hemi-seasons
'("Forårsjævndøgn" "Sommersolhverv"
"Efterårsjævndøgn" "Vintersolhverv"))
(setq solar-s-hemi-seasons
'("Efterårsjævndøgn" "Vintersolhverv"
"Forårsjævndøgn" "Sommersolhverv"))))
;; Moon phace names
(defadvice lunar-phase-name (around da-lunar-phase-name activate)
"Phases of the moon in danish."
(setq ad-return-value
(let ((phase (ad-get-arg 0)))
(cond ((= 0 phase) "Nymåne")
((= 1 phase) "Tiltagende Halvmåne")
((= 2 phase) "Fuldmåne")
((= 3 phase) "Aftagende Halvmåne")))))
;; Sunrise and sunset
(defadvice solar-sunrise-sunset-string (around da-solar-sunrise-sunset-string
activate)
"Sunrise and sunset in danish."
(setq ad-return-value
(let ((l (solar-sunrise-sunset date)))
(format
"%s, %s i %s (%s timers dagslys)"
(if (car l)
(concat "Sol op " (apply 'solar-time-string (car l)))
"Ingen solopgang")
(if (car (cdr l))
(concat "ned " (apply 'solar-time-string (car (cdr l))))
"ingen solnedgang")
(eval calendar-location-name)
(car (cdr (cdr l)))))))
;; Show week number
;; Adapted from http://stackoverflow.com/questions/21364948/how-to-align-the-calendar-with-week-number-as-the-intermonth-text
(setq calendar-intermonth-text
'(propertize
(format "%2d"
(car
(calendar-iso-from-absolute
(calendar-absolute-from-gregorian (list month day year)))))
'font-lock-face 'font-lock-doc-face))
;; Week numbers are very common and there's no two-letter abreviation for it,
;; Thus I'm not added a header. It could be added using this (ug=ugenummer):
;;
;; (setq calendar-intermonth-header nil)
;; (propertize "un" 'font-lock-face 'font-lock-keyword-face))
;; Calculation of easter, the fix point for many holidays (taken from
;; sv-kalender.el, originally from holiday-easter-etc)
(defun da-easter (year)
"Calculate the date for Easter in YEAR."
(let* ((century (1+ (/ year 100)))
(shifted-epact (% (+ 14 (* 11 (% year 19))
(- (/ (* 3 century) 4))
(/ (+ 5 (* 8 century)) 25)
(* 30 century))
30))
(adjusted-epact (if (or (= shifted-epact 0)
(and (= shifted-epact 1)
(< 10 (% year 19))))
(1+ shifted-epact)
shifted-epact))
(paschal-moon (- (calendar-absolute-from-gregorian
(list 4 19 year))
adjusted-epact)))
(calendar-dayname-on-or-before 0 (+ paschal-moon 7))))
(setq general-holidays
'((holiday-fixed 1 1 "Nytårsdag")
(holiday-fixed 1 6 "Hellige 3 konger")
;; Easter and Pentecost
(holiday-filter-visible-calendar
(mapcar
(lambda (dag)
(list (calendar-gregorian-from-absolute
(+ (da-easter displayed-year) (car dag)))
(cadr dag)))
'(( -49 "Fastelavn")
( -7 "Palmesøndag")
( -3 "Skærtorsdag")
( -2 "Langfredag")
( 0 "Påskedag")
( +1 "Anden påskedag")
( +26 "Store bededag")
( +39 "Kristi himmelfartsdag")
( +49 "Pinsedag")
( +50 "Anden pinsedag"))))
(holiday-fixed 12 24 "Juleaften")
(holiday-fixed 12 25 "Juledag")
(holiday-fixed 12 26 "Anden juledag")
(holiday-fixed 12 31 "Nytårsaften")))
(setq other-holidays
'((holiday-fixed 3 8 "Kvindernes internationale kampdag")
(holiday-fixed 5 1 "Arbejdernes internationale kampdag")
(holiday-fixed 5 4 "Danmarks befrielse")
(holiday-float 5 0 2 "Mors dag")
(holiday-fixed 6 5 "Grundlovsdag")
(holiday-fixed 6 5 "Fars dag")
(holiday-fixed 6 15 "Valdemarsdag (Dannebrog)")
(holiday-fixed 6 24 "Skt. Hans dag")))
(setq calendar-holidays
(append general-holidays other-holidays))
;;; da-kalender.el ends here