gnu: Add date.
[jackhill/guix/guix.git] / gnu / packages / calendar.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
3 ;;; Copyright © 2015, 2016, 2017 Leo Famulari <leo@famulari.name>
4 ;;; Copyright © 2016 Kei Kebreau <kkebreau@posteo.net>
5 ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2016 Troy Sankey <sankeytms@gmail.com>
7 ;;; Copyright © 2016 Stefan Reichoer <stefan@xsteve.at>
8 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com
10 ;;; Copyright © 2020 Brendan Tildesley <mail@brendan.scot>
11 ;;;
12 ;;; This file is part of GNU Guix.
13 ;;;
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
18 ;;;
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
23 ;;;
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27 (define-module (gnu packages calendar)
28 #:use-module (gnu packages)
29 #:use-module ((guix licenses) #:prefix license:)
30 #:use-module (guix git-download)
31 #:use-module (guix packages)
32 #:use-module (guix download)
33 #:use-module (guix build-system gnu)
34 #:use-module (guix build-system cmake)
35 #:use-module (guix build-system python)
36 #:use-module (gnu packages base)
37 #:use-module (gnu packages check)
38 #:use-module (gnu packages dav)
39 #:use-module (gnu packages freedesktop)
40 #:use-module (gnu packages glib)
41 #:use-module (gnu packages gtk)
42 #:use-module (gnu packages icu4c)
43 #:use-module (gnu packages perl)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages python)
46 #:use-module (gnu packages python-xyz)
47 #:use-module (gnu packages sphinx)
48 #:use-module (gnu packages sqlite)
49 #:use-module (gnu packages time)
50 #:use-module (gnu packages xml)
51 #:use-module (srfi srfi-26))
52
53 (define-public date
54 ;; We make the same choice as the Arch package maintainer by choosing a
55 ;; recent commit to fix some bugs.
56 ;; https://github.com/Alexays/Waybar/issues/565
57 (let ((commit "9a0ee2542848ab8625984fc8cdbfb9b5414c0082"))
58 (package
59 (name "date")
60 (version (string-append "2.4.1-" (string-take commit 8)))
61 (source
62 (origin
63 (method git-fetch)
64 (uri (git-reference
65 (url "https://github.com/HowardHinnant/date.git")
66 (commit "9a0ee2542848ab8625984fc8cdbfb9b5414c0082")))
67 (file-name (git-file-name name version))
68 (sha256
69 (base32 "0yxsn0hj22n61bjywysxqgfv7hj5xvsl6isma95fl8xrimpny083"))
70 (patches
71 ;; Install pkg-config files
72 ;; https://github.com/HowardHinnant/date/pull/538
73 (search-patches "date-output-pkg-config-files.patch"))))
74 (inputs `(("tzdata" ,tzdata)))
75 (build-system cmake-build-system)
76 (arguments
77 '(#:configure-flags (list "-DUSE_SYSTEM_TZ_DB=ON"
78 "-DBUILD_SHARED_LIBS=ON"
79 "-DBUILD_TZ_LIB=ON"
80 "-DENABLE_DATE_TESTING=ON")
81 #:phases
82 (modify-phases %standard-phases
83 (add-after 'unpack 'patch-bin-bash
84 (lambda* (#:key inputs #:allow-other-keys)
85 (substitute* "compile_fail.sh"
86 (("/bin/bash") (which "bash")))
87 #t))
88 (add-after 'unpack 'patch-zoneinfo-path
89 (lambda* (#:key inputs #:allow-other-keys)
90 (substitute* "src/tz.cpp"
91 (("/usr/share/zoneinfo")
92 (string-append (assoc-ref inputs "tzdata") "/share/zoneinfo")))
93 #t))
94 (replace 'check
95 (lambda _
96 ;; Disable test that requires checking timezone that
97 ;; isn't set in the build environment.
98 (substitute* "CTestTestfile.cmake"
99 (("add_test.tz_test_pass_zoned_time_deduction_test.*") "")
100 (("set_tests_properties.tz_test_pass_zoned_time_deduction_test.*") ""))
101 (invoke "make" "testit"))))))
102 (synopsis "Date and time library for C++11 and C++14")
103 (description "Date is a header only C++ library that extends the chrono
104 date algorithms library for calendar dates and durations. It also provides
105 the <tz.h> library for handling time zones and leap seconds.")
106 (home-page "https://howardhinnant.github.io/date/date.html")
107 (license license:expat))))
108
109 (define-public libical
110 (package
111 (name "libical")
112 (version "3.0.7")
113 (source (origin
114 (method url-fetch)
115 (uri (string-append
116 "https://github.com/libical/libical/releases/download/v"
117 version "/libical-" version ".tar.gz"))
118 (sha256
119 (base32
120 "1z33wzaazbd7drl6qbh1750whd78xl2cg0gjnxyya9m83vgndgha"))
121 (patches
122 ;; Add a patch slated for 3.0.8 which preserves backwards-
123 ;; compatibility in the icalattach_new_from_data() function,
124 ;; which accidentally changed in 3.0.7 and could break some uses.
125 ;; https://gitlab.gnome.org/GNOME/evolution-data-server/issues/185
126 ;; http://lists.infradead.org/pipermail/libical-devel/2020-January/000907.html
127 (list (origin
128 (method url-fetch)
129 (uri (string-append
130 "https://github.com/libical/libical/commit/"
131 "ae394010c889e4c185160da5e81527849f9de350.patch"))
132 (file-name "libical-3.0.7-preserve-icalattach-api.patch")
133 (sha256
134 (base32
135 "0v8qcxn8a6sh78grzxd61j9478928dx38l5mf8mkdrbxv47vmvvp")))))))
136 (build-system cmake-build-system)
137 (arguments
138 '(#:tests? #f ; test suite appears broken
139 #:configure-flags '("-DSHARED_ONLY=true")
140 #:phases
141 (modify-phases %standard-phases
142 (add-before 'configure 'patch-paths
143 (lambda* (#:key inputs #:allow-other-keys)
144 ;; TODO: libical 3.1.0 supports using TZDIR instead of a hard-coded
145 ;; zoneinfo database. When that is released we can drop
146 ;; the tzdata dependency.
147 (let ((tzdata (assoc-ref inputs "tzdata")))
148 (substitute* "src/libical/icaltz-util.c"
149 (("\\\"/usr/share/zoneinfo\\\",")
150 (string-append "\"" tzdata "/share/zoneinfo\""))
151 (("\\\"/usr/lib/zoneinfo\\\",") "")
152 (("\\\"/etc/zoneinfo\\\",") "")
153 (("\\\"/usr/share/lib/zoneinfo\\\"") "")))
154 #t)))))
155 (native-inputs
156 `(("gtk-doc" ,gtk-doc)
157 ("perl" ,perl)
158 ("pkg-config" ,pkg-config)))
159 (inputs
160 `(("glib" ,glib)
161 ("libxml2" ,libxml2)
162 ("tzdata" ,tzdata)))
163 (propagated-inputs
164 ;; In Requires.private of libical.pc.
165 `(("icu4c" ,icu4c)))
166 (home-page "https://libical.github.io/libical/")
167 (synopsis "iCalendar protocols and data formats implementation")
168 (description
169 "Libical is an implementation of the iCalendar protocols and protocol
170 data units.")
171 ;; Can be used with either license. See COPYING.
172 (license (list license:lgpl2.1 license:mpl2.0))))
173
174 (define-public khal
175 (package
176 (name "khal")
177 (version "0.10.1")
178 (source (origin
179 (method url-fetch)
180 (uri (pypi-uri "khal" version))
181 (sha256
182 (base32
183 "1r8bkgjwkh7i8ygvsv51h1cnax50sb183vafg66x5snxf3dgjl6l"))))
184 (build-system python-build-system)
185 (arguments
186 `(#:phases (modify-phases %standard-phases
187 ;; Building the manpage requires khal to be installed.
188 (add-after 'install 'manpage
189 (lambda* (#:key inputs outputs #:allow-other-keys)
190 ;; Make installed package available for running the tests
191 (add-installed-pythonpath inputs outputs)
192 (invoke "make" "--directory=doc/" "man")
193 (install-file
194 "doc/build/man/khal.1"
195 (string-append (assoc-ref outputs "out") "/share/man/man1"))
196 #t))
197 (replace 'check
198 (lambda* (#:key inputs #:allow-other-keys)
199 ;; The tests require us to choose a timezone.
200 (setenv "TZ"
201 (string-append (assoc-ref inputs "tzdata")
202 "/share/zoneinfo/Zulu"))
203 (invoke "py.test" "tests"))))))
204 (native-inputs
205 `(("python-pytest" ,python-pytest)
206 ("python-pytest-cov" ,python-pytest-cov)
207 ("python-setuptools-scm" ,python-setuptools-scm)
208 ;; Required for tests
209 ("python-freezegun" ,python-freezegun)
210 ("tzdata" ,tzdata-for-tests)
211 ("vdirsyncer" ,vdirsyncer)
212 ;; Required to build manpage
213 ("python-sphinxcontrib-newsfeed" ,python-sphinxcontrib-newsfeed)
214 ("python-sphinx" ,python-sphinx)))
215 (inputs
216 `(("sqlite" ,sqlite)))
217 (propagated-inputs
218 `(("python-configobj" ,python-configobj)
219 ("python-dateutil" ,python-dateutil)
220 ("python-icalendar" ,python-icalendar)
221 ("python-tzlocal" ,python-tzlocal)
222 ("python-urwid" ,python-urwid)
223 ("python-pyxdg" ,python-pyxdg)))
224 (synopsis "Console calendar program")
225 (description "Khal is a standards based console calendar program,
226 able to synchronize with CalDAV servers through vdirsyncer.")
227 (home-page "https://lostpackets.de/khal/")
228 (license license:expat)))
229
230 (define-public remind
231 (package
232 (name "remind")
233 (version "3.1.17")
234 (source
235 (origin
236 (method url-fetch)
237 (uri (string-append "https://dianne.skoll.ca/projects/remind/download/"
238 "remind-"
239 (string-join (map (cut string-pad <> 2 #\0)
240 (string-split version #\.))
241 ".")
242 ".tar.gz"))
243 (sha256
244 (base32 "0lgyc2j69aqqk4knywr8inz4fsnni0zq54dgqh7p4s6kzybc2mf9"))))
245 (build-system gnu-build-system)
246 (arguments
247 '(#:tests? #f)) ; no "check" target
248 (home-page "https://dianne.skoll.ca/projects/remind/")
249 (synopsis "Sophisticated calendar and alarm program")
250 (description
251 "Remind allows you to remind yourself of upcoming events and appointments.
252 Each reminder or alarm can consist of a message sent to standard output, or a
253 program to be executed. It also features: sophisticated date calculation,
254 moon phases, sunrise/sunset, Hebrew calendar, alarms, PostScript output and
255 proper handling of holidays.")
256 (license license:gpl2)))
257
258 (define-public libhdate
259 (package
260 (name "libhdate")
261 (version "1.6.02")
262 (source
263 (origin
264 (method url-fetch)
265 (uri (string-append "mirror://sourceforge/libhdate/libhdate/libhdate-"
266 version "/" name "-" version ".tar.bz2"))
267 (sha256
268 (base32
269 "0qkpq412p78znw8gckwcx3l0wcss9s0dgw1pvjb1ih2pxf6hm4rw"))))
270 (build-system gnu-build-system)
271 (home-page "http://libhdate.sourceforge.net/")
272 (synopsis "Library to use Hebrew dates")
273 (description "LibHdate is a small library for the Hebrew calendar and times
274 of day, written in C, and including bindings for C++, pascal, perl, php, python,
275 and ruby. It includes two illustrative command-line programs, @code{hcal} and
276 @code{hdate}, and some snippets and scripts written in the binding languages.")
277 (license license:gpl3+)))