time.scm 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
  3. ;;; Copyright © 2013, 2017, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
  4. ;;; Copyright © 2013, 2015 Andreas Enge <andreas@enge.fr>
  5. ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2021 Efraim Flashner <efraim@flashner.co.il>
  6. ;;; Copyright © 2015, 2017 Leo Famulari <leo@famulari.name>
  7. ;;; Copyright © 2015, 2017 Cyril Roelandt <tipecaml@gmail.com>
  8. ;;; Copyright © 2016 Sou Bunnbu <iyzsong@gmail.com>
  9. ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
  10. ;;; Copyright © 2016 Danny Milosavljevic <dannym+a@scratchpost.org>
  11. ;;; Copyright © 2016, 2020 Marius Bakke <mbakke@fastmail.com>
  12. ;;; Copyright © 2016, 2017, 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
  13. ;;; Copyright © 2017 Ben Woodcroft <donttrustben@gmail.com>
  14. ;;; Copyright © 2017 Nikita <nikita@n0.is>
  15. ;;; Copyright © 2017 Julien Lepiller <julien@lepiller.eu>
  16. ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
  17. ;;; Copyright © 2019 Kyle Meyer <kyle@kyleam.com>
  18. ;;; Copyright © 2019 Pierre Langlois <pierre.langlois@gmx.com>
  19. ;;; Copyright © 2020 Lars-Dominik Braun <ldb@leibniz-psychology.org>
  20. ;;; Copyright © 2020 Tanguy Le Carrour <tanguy@bioneland.org>
  21. ;;; Copyright © 2021 Ryan Prior <rprior@protonmail.com>
  22. ;;;
  23. ;;; This file is part of GNU Guix.
  24. ;;;
  25. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  26. ;;; under the terms of the GNU General Public License as published by
  27. ;;; the Free Software Foundation; either version 3 of the License, or (at
  28. ;;; your option) any later version.
  29. ;;;
  30. ;;; GNU Guix is distributed in the hope that it will be useful, but
  31. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  32. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  33. ;;; GNU General Public License for more details.
  34. ;;;
  35. ;;; You should have received a copy of the GNU General Public License
  36. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  37. (define-module (gnu packages time)
  38. #:use-module (gnu packages check)
  39. #:use-module (gnu packages compression)
  40. #:use-module (gnu packages golang)
  41. #:use-module (gnu packages perl)
  42. #:use-module (gnu packages python)
  43. #:use-module (gnu packages python-xyz)
  44. #:use-module (gnu packages terminals)
  45. #:use-module (gnu packages textutils)
  46. #:use-module (gnu packages)
  47. #:use-module (guix build-system gnu)
  48. #:use-module (guix build-system go)
  49. #:use-module (guix build-system python)
  50. #:use-module (guix download)
  51. #:use-module (guix git-download)
  52. #:use-module (guix licenses)
  53. #:use-module (guix packages))
  54. (define-public time
  55. (package
  56. (name "time")
  57. (version "1.9")
  58. (source
  59. (origin
  60. (method url-fetch)
  61. (uri (string-append "mirror://gnu/time/time-"
  62. version ".tar.gz"))
  63. (sha256
  64. (base32
  65. "07jj7cz6lc13iqrpgn81ivqh8rkm73p4rnivwgrrshk23v4g1b7v"))))
  66. (build-system gnu-build-system)
  67. (home-page "https://www.gnu.org/software/time/")
  68. (synopsis "Run a command, then display its resource usage")
  69. (description
  70. "Time is a command that displays information about the resources that a
  71. program uses. The display output of the program can be customized or saved
  72. to a file.")
  73. (license gpl3+)))
  74. (define-public python-pytimeparse
  75. (package
  76. (name "python-pytimeparse")
  77. (version "1.1.8")
  78. (source
  79. (origin
  80. (method url-fetch)
  81. (uri (pypi-uri "pytimeparse" version))
  82. (sha256
  83. (base32
  84. "02kaambsgpjx3zi42j6l11rwms2p35b9hsk4f3kdf979gd3kcqg8"))))
  85. (native-inputs
  86. `(("python-nose" ,python-nose)))
  87. (build-system python-build-system)
  88. (home-page "https://github.com/wroberts/pytimeparse")
  89. (synopsis "Time expression parser")
  90. (description "This small Python module parses various kinds of time
  91. expressions.")
  92. (license expat)))
  93. (define-public python-pytzdata
  94. (package
  95. (name "python-pytzdata")
  96. (version "2020.1")
  97. (source
  98. (origin
  99. (method url-fetch)
  100. (uri (pypi-uri "pytzdata" version))
  101. (sha256
  102. (base32
  103. "0h0md0ldhb8ghlwjslkzh3wcj4fxg3n43bj5sghqs2m06nri7yiy"))))
  104. (build-system python-build-system)
  105. ;; XXX: The PyPI distribution contains no tests, and the upstream
  106. ;; repository lacks a setup.py! How to build from git?
  107. (arguments '(#:tests? #f))
  108. (propagated-inputs
  109. `(("python-cleo" ,python-cleo)))
  110. (home-page "https://github.com/sdispater/pytzdata")
  111. (synopsis "Timezone database for Python")
  112. (description
  113. "This library provides a timezone database for Python.")
  114. (license expat)))
  115. (define-public python2-tzdata
  116. (package-with-python2 python-pytzdata))
  117. (define-public python-pytz
  118. (package
  119. (name "python-pytz")
  120. ;; This package should be kept in sync with tzdata in (gnu packages base).
  121. (version "2021.1")
  122. (source
  123. (origin
  124. (method url-fetch)
  125. (uri (pypi-uri "pytz" version))
  126. (sha256
  127. (base32
  128. "1nn459q7zg20n75akxl3ljkykgw1ydc8nb05rx1y4f5zjh4ak943"))))
  129. (build-system python-build-system)
  130. (home-page "http://pythonhosted.org/pytz")
  131. (synopsis "Python timezone library")
  132. (description "This library brings the Olson tz database into Python. It
  133. allows accurate and cross platform timezone calculations using Python 2.4 or
  134. higher. It also solves the issue of ambiguous times at the end of daylight
  135. saving time. Almost all of the Olson timezones are supported.")
  136. (license expat)))
  137. (define-public python2-pytz
  138. (package-with-python2 python-pytz))
  139. (define-public python-pendulum
  140. (package
  141. (name "python-pendulum")
  142. (version "2.1.2")
  143. (source
  144. (origin
  145. (method url-fetch)
  146. (uri (pypi-uri "pendulum" version))
  147. (sha256
  148. (base32 "01zjc245w08j0xryrgrq9vng59q1cl5ry0hcpw5rj774pyhhqsmh"))))
  149. (build-system python-build-system)
  150. ;; XXX: The PyPI distribution lacks tests, and the upstream repository
  151. ;; lacks a setup.py!
  152. (arguments '(#:tests? #f))
  153. (propagated-inputs
  154. `(("python-dateutil" ,python-dateutil)
  155. ("python-pytzdata" ,python-pytzdata)))
  156. (home-page "https://github.com/sdispater/pendulum")
  157. (synopsis "Alternate API for Python datetimes")
  158. (description "Pendulum is a drop-in replacement for the standard
  159. @{datetime} class, providing an alternative API. As it inherits from the
  160. standard @code{datetime} all @code{datetime} instances can be replaced by
  161. Pendulum instances.")
  162. (license expat)))
  163. (define-public python-dateutil
  164. (package
  165. (name "python-dateutil")
  166. (version "2.8.1")
  167. (source
  168. (origin
  169. (method url-fetch)
  170. (uri (pypi-uri "python-dateutil" version))
  171. (sha256
  172. (base32
  173. "0g42w7k5007iv9dam6gnja2ry8ydwirh99mgdll35s12pyfzxsvk"))))
  174. (build-system python-build-system)
  175. (arguments
  176. `(#:phases (modify-phases %standard-phases
  177. (replace 'check
  178. (lambda _
  179. ;; Delete tests that depend on "freezegun" to avoid a
  180. ;; circular dependency.
  181. (delete-file "dateutil/test/test_utils.py")
  182. (delete-file "dateutil/test/test_rrule.py")
  183. ;; XXX: Fails to get timezone from /etc/localtime.
  184. (delete-file "dateutil/test/test_tz.py")
  185. (invoke "pytest" "-vv"))))))
  186. (native-inputs
  187. `(("python-pytest" ,python-pytest)
  188. ("python-pytest-cov" ,python-pytest-cov)
  189. ("python-setuptools-scm" ,python-setuptools-scm)))
  190. (propagated-inputs
  191. `(("python-six" ,python-six)))
  192. (home-page "https://dateutil.readthedocs.io/en/stable/")
  193. (synopsis "Extensions to the standard datetime module")
  194. (description
  195. "The dateutil module provides powerful extensions to the standard
  196. datetime module, available in Python 2.3+.")
  197. ;; The license was changed from the three-clause BSD license to a dual
  198. ;; Apache 2.0/BSD-3 variant at 2017-12-01. Some code is only available as
  199. ;; BSD-3 still; but all new code is dual licensed (the user can choose).
  200. (license (list bsd-3 asl2.0))))
  201. (define-public python2-dateutil
  202. (package-with-python2 python-dateutil))
  203. (define-public python-parsedatetime
  204. (package
  205. (name "python-parsedatetime")
  206. (version "2.4")
  207. (source
  208. (origin
  209. (method url-fetch)
  210. (uri (pypi-uri "parsedatetime" version))
  211. (sha256
  212. (base32
  213. "0jxqkjks7z9dn222cqgvskp4wr6d92aglinxq7pd2w4mzdc7r09x"))))
  214. (build-system python-build-system)
  215. (native-inputs
  216. `(("python-nose" ,python-nose)
  217. ("python-pyicu" ,python-pyicu)
  218. ("python-pytest" ,python-pytest)
  219. ("python-pytest-runner" ,python-pytest-runner)))
  220. (propagated-inputs
  221. `(("python-future" ,python-future)))
  222. (home-page "https://github.com/bear/parsedatetime/")
  223. (synopsis "Parse human-readable date/time text")
  224. (description
  225. "Parse human-readable date/time text.")
  226. (license asl2.0)))
  227. (define-public python2-parsedatetime
  228. (package-with-python2 python-parsedatetime))
  229. (define-public python-ciso8601
  230. (package
  231. (name "python-ciso8601")
  232. (version "2.1.3")
  233. (source
  234. (origin
  235. (method git-fetch)
  236. ;; The PyPi distribution doesn't include the tests.
  237. (uri (git-reference
  238. (url "https://github.com/closeio/ciso8601")
  239. (commit (string-append "v" version))))
  240. (file-name (git-file-name name version))
  241. (sha256
  242. (base32
  243. "0g1aiyc1ayh0rnibyy416m5mmck38ksgdm3jsy0z3rxgmgb24951"))))
  244. (build-system python-build-system)
  245. ;; Pytz should only be required for Python 2, but the test suite fails
  246. ;; without it.
  247. (native-inputs
  248. `(("python-pytz" ,python-pytz)))
  249. (home-page "https://github.com/closeio/ciso8601")
  250. (synopsis
  251. "Fast ISO8601 date time parser")
  252. (description
  253. "The package ciso8601 converts ISO 8601 or RFC 3339 date time strings into
  254. Python datetime objects.")
  255. (license expat)))
  256. (define-public python-tzlocal
  257. (package
  258. (name "python-tzlocal")
  259. (version "2.1")
  260. (source
  261. (origin
  262. (method url-fetch)
  263. (uri (pypi-uri "tzlocal" version))
  264. (sha256
  265. (base32
  266. "0i1fm4sl04y65qnaqki0w75j34w863gxjj8ag0vwgvaa572rfg34"))))
  267. (build-system python-build-system)
  268. (arguments
  269. `(#:phases
  270. (modify-phases %standard-phases
  271. (add-before 'check 'fix-symlink-test
  272. ;; see: https://github.com/regebro/tzlocal/issues/53
  273. (lambda _
  274. (delete-file "tests/test_data/symlink_localtime/etc/localtime")
  275. (symlink "../usr/share/zoneinfo/Africa/Harare"
  276. "tests/test_data/symlink_localtime/etc/localtime")
  277. ;; And skip the test_fail test, it is known to fail
  278. (substitute* "tests/tests.py"
  279. (("def test_fail") "def _test_fail"))
  280. #t)))))
  281. (propagated-inputs
  282. `(("python-pytz" ,python-pytz)))
  283. (native-inputs
  284. `(("python-mock" ,python-mock)))
  285. (home-page "https://github.com/regebro/tzlocal")
  286. (synopsis "Local timezone information for Python")
  287. (description
  288. "Tzlocal returns a tzinfo object with the local timezone information.
  289. This module attempts to fix a glaring hole in pytz, that there is no way to
  290. get the local timezone information, unless you know the zoneinfo name, and
  291. under several distributions that's hard or impossible to figure out.")
  292. (license expat)))
  293. (define-public python-isodate
  294. (package
  295. (name "python-isodate")
  296. (version "0.6.0")
  297. (source
  298. (origin
  299. (method url-fetch)
  300. (uri (pypi-uri "isodate" version))
  301. (sha256
  302. (base32
  303. "1n7jkz68kk5pwni540pr5zdh99bf6ywydk1p5pdrqisrawylldif"))))
  304. (build-system python-build-system)
  305. (native-inputs
  306. `(("python-six" ,python-six)))
  307. (home-page "https://github.com/gweis/isodate/")
  308. (synopsis "Python date parser and formatter")
  309. (description
  310. "Python-isodate is a python module for parsing and formatting
  311. ISO 8601 dates, time and duration.")
  312. (license bsd-3)))
  313. (define-public python2-isodate
  314. (package-with-python2 python-isodate))
  315. (define-public python-iso8601
  316. (package
  317. (name "python-iso8601")
  318. (version "0.1.13")
  319. (source
  320. (origin
  321. (method url-fetch)
  322. (uri (pypi-uri "iso8601" version))
  323. (sha256
  324. (base32
  325. "1cgfj91khil4ii5gb8s6nxwm73vx7hqc2k79dd9d8990ylmc5ppp"))))
  326. (build-system python-build-system)
  327. (arguments
  328. '(#:phases (modify-phases %standard-phases
  329. (replace 'check
  330. (lambda _
  331. (invoke "pytest" "-vv" "iso8601"))))))
  332. (native-inputs
  333. `(("python-pytest" ,python-pytest)))
  334. (home-page "https://bitbucket.org/micktwomey/pyiso8601")
  335. (synopsis "Module to parse ISO 8601 dates")
  336. (description
  337. "This module parses the most common forms of ISO 8601 date strings (e.g.
  338. @code{2007-01-14T20:34:22+00:00}) into @code{datetime} objects.")
  339. (license expat)))
  340. (define-public python2-iso8601
  341. (package-with-python2 python-iso8601))
  342. (define-public python-monotonic
  343. (package
  344. (name "python-monotonic")
  345. (version "1.5")
  346. (source
  347. (origin
  348. (method url-fetch)
  349. (uri (pypi-uri "monotonic" version))
  350. (sha256
  351. (base32
  352. "1c6z46yb600klbfhqadyl7vq0jdjdxkm72k43ra3iw3d0xakv593"))))
  353. (build-system python-build-system)
  354. (arguments '(#:tests? #f)) ; no tests
  355. (home-page "https://github.com/atdt/monotonic")
  356. (synopsis "Implementation of time.monotonic() for Python 2 & < 3.3")
  357. (description
  358. "This module provides a @code{monotonic()} function which returns the
  359. value (in fractional seconds) of a clock which never goes backwards.")
  360. (license asl2.0)))
  361. (define-public python2-monotonic
  362. (package-with-python2 python-monotonic))
  363. (define-public python-pyrfc3339
  364. (package
  365. (name "python-pyrfc3339")
  366. (version "1.1")
  367. (source
  368. (origin
  369. (method url-fetch)
  370. (uri (pypi-uri "pyRFC3339" version))
  371. (sha256
  372. (base32
  373. "06jv7ar7lpvvk0dixzwdr3wgm0g1lipxs429s2z7knwwa7hwpf41"))))
  374. (build-system python-build-system)
  375. (propagated-inputs
  376. `(("python-pytz" ,python-pytz)))
  377. (native-inputs
  378. `(("python-nose" ,python-nose)))
  379. (home-page "https://github.com/kurtraschke/pyRFC3339")
  380. (synopsis "Python timestamp library")
  381. (description "Python library for generating and parsing RFC 3339-compliant
  382. timestamps.")
  383. (license expat)))
  384. (define-public python2-pyrfc3339
  385. (package-with-python2 python-pyrfc3339))
  386. (define-public python-arrow
  387. (package
  388. (name "python-arrow")
  389. (version "1.1.1")
  390. (source (origin
  391. (method url-fetch)
  392. (uri (pypi-uri "arrow" version))
  393. (sha256
  394. (base32
  395. "0fl24gv7jc6b9pqxwlcgrf465i8v8h0y7dcm018yrqv0dhpn1ryy"))))
  396. (build-system python-build-system)
  397. (arguments
  398. `(#:phases
  399. (modify-phases %standard-phases
  400. (replace 'check
  401. (lambda* (#:key tests? #:allow-other-keys)
  402. (when tests?
  403. (invoke "pytest" "-vv" "tests"
  404. ;; python-dateutil doesn't recognize America/Nuuk.
  405. ;; Remove when python-dateutil > 2.8.1.
  406. "-k" "not test_parse_tz_name_zzz")))))))
  407. (native-inputs
  408. `(;; For testing
  409. ("python-chai" ,python-chai)
  410. ("python-pytest" ,python-pytest)
  411. ("python-pytest-cov" ,python-pytest-cov)
  412. ("python-pytest-mock" ,python-pytest-mock)
  413. ("python-simplejson" ,python-simplejson)))
  414. (propagated-inputs
  415. `(("python-dateutil" ,python-dateutil)
  416. ("python-pytz" ,python-pytz)))
  417. (home-page "https://github.com/arrow-py/arrow")
  418. (synopsis "Dates and times for Python")
  419. (description
  420. "Arrow is a Python library to creating, manipulating, formatting and
  421. converting dates, times, and timestamps. It implements and updates the
  422. datetime type.")
  423. (license asl2.0)))
  424. (define-public python-aniso8601
  425. (package
  426. (name "python-aniso8601")
  427. (version "1.3.0")
  428. (source
  429. (origin
  430. (method url-fetch)
  431. (uri (pypi-uri "aniso8601" version))
  432. (sha256
  433. (base32
  434. "1waj54iv3n3lw1fapbz8a93yjgrybgpc86wif5baxdh1arpj9df3"))))
  435. (build-system python-build-system)
  436. (propagated-inputs
  437. `(("python-dateutil" ,python-dateutil)))
  438. (home-page "https://bitbucket.org/nielsenb/aniso8601")
  439. (synopsis "Python library for parsing ISO 8601 strings")
  440. (description
  441. "This package contains a library for parsing ISO 8601 datetime strings.")
  442. (license bsd-3)))
  443. (define-public python2-aniso8601
  444. (package-with-python2 python-aniso8601))
  445. (define-public datefudge
  446. (package
  447. (name "datefudge")
  448. (version "1.23")
  449. (source (origin
  450. ;; Source code is available from
  451. ;; <https://salsa.debian.org/debian/datefudge.git>. However,
  452. ;; for bootstrapping reasons, we do not rely on 'git-fetch' here
  453. ;; (since Git -> GnuTLS -> datefudge).
  454. (method url-fetch)
  455. (uri (string-append
  456. "mirror://debian/pool/main/d/datefudge/datefudge_"
  457. version ".tar.xz"))
  458. (sha256
  459. (base32
  460. "0ifnlb0mc8qc2kb5042pbz0ns6rwcb7201di8wyrsphl0yhnhxiv"))
  461. (patches (search-patches "datefudge-gettimeofday.patch"))))
  462. (build-system gnu-build-system)
  463. (arguments
  464. `(#:test-target "test"
  465. #:make-flags (list "CC=gcc"
  466. (string-append "prefix=" (assoc-ref %outputs "out")))
  467. #:phases
  468. (modify-phases %standard-phases
  469. (add-after 'unpack 'patch-makefile
  470. (lambda _
  471. (substitute* "Makefile"
  472. ((" -o root -g root") "")
  473. (("VERSION := \\$\\(shell dpkg-parsechangelog .*")
  474. (string-append "VERSION = " ,version)))
  475. #t))
  476. (delete 'configure))))
  477. (native-inputs
  478. `(("perl" ,perl)))
  479. (home-page "https://salsa.debian.org/debian/datefudge")
  480. (synopsis "Pretend the system date is different")
  481. (description
  482. "Utility that fakes the system time by pre-loading a small library that
  483. modifies the @code{time}, @code{gettimeofday} and @code{clock_gettime} system
  484. calls.")
  485. (license gpl2)))
  486. (define-public countdown
  487. (package
  488. (name "countdown")
  489. (version "1.0.0")
  490. (source
  491. (origin
  492. (method git-fetch)
  493. (uri (git-reference
  494. (url "https://github.com/antonmedv/countdown")
  495. (commit (string-append "v" version))))
  496. (file-name (git-file-name name version))
  497. (sha256
  498. (base32 "0pdaw1krr0bsl4amhwx03v2b02iznvwvqn7af5zp4fkzjaj14cdw"))))
  499. (build-system go-build-system)
  500. (arguments
  501. '(#:import-path "github.com/antonmedv/countdown"))
  502. (native-inputs
  503. `(("runewidth" ,go-github.com-mattn-go-runewidth)
  504. ("termbox" ,go-github.com-nsf-termbox-go)))
  505. (home-page "https://github.com/antonmedv/countdown")
  506. (synopsis "Counts to zero with a text user interface")
  507. (description
  508. "Countdown provides a fancy text display while it counts down to zero
  509. from a starting point you provide. The user can pause and resume the
  510. countdown from the text user interface.")
  511. (license expat)))