]> code.delx.au - gnu-emacs-elpa/blob - packages/notes-mode/notes-aux.el
Merge commit '0cda39255827f283e7578cd469ae42daad9556a2' from js2-mode
[gnu-emacs-elpa] / packages / notes-mode / notes-aux.el
1 ;;; notes-aux.el --- Auxiliary functions for notes-mode and friends
2
3 ;; Copyright (C) 1994,1995,1998,2012 Free Software Foundation, Inc.
4
5 ;; Author: <johnh@isi.edu>.
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22 ;;; Commentary:
23
24 ;;; Code:
25
26 ;;;###autoload
27 ;;(defun notes-format-date (&optional calendar-date)
28 ;; "Format the calendar-date-style DATE up to be a notes-format date.
29 ;;If no DATE is specified, use today's date."
30 ;; (require 'calendar)
31 ;; (let* ((date (if calendar-date
32 ;; calendar-date
33 ;; (calendar-current-date)))
34 ;; (month (car date))
35 ;; (day (nth 1 date))
36 ;; (year (nth 2 date)))
37 ;; (format "%02d%02d%02d" (- year 1900) month day)))
38 (defun notes-format-date (&optional time)
39 "Format the TIME up to be a notes-format date.
40 If no TIME is specified, use today's date."
41 (require 'notes-variables)
42 (if (null time)
43 (setq time (current-time)))
44 (format-time-string notes-file-form time))
45
46 (defun notes-file-to-epoch (file)
47 "Convert a notes FILE to an epoch time."
48 (string-match notes-file-regexp file)
49 (let
50 ((y (string-to-number (match-string 1 file)))
51 (m (string-to-number (match-string 2 file)))
52 (d (string-to-number (match-string 3 file))))
53 (if (< y 1900)
54 (setq y (+ y 1900)))
55 (if (< y 1970)
56 (setq y (+ y 100)))
57 (encode-time 0 0 12 d m y)))
58
59 (defun notes-file-to-url (file &optional tag)
60 "Convert a notes FILE to a URL with an optional TAG."
61 (let
62 ((epoch (notes-file-to-epoch file)))
63 (concat
64 notes-url-prefix
65 (format-time-string notes-int-form epoch)
66 "/"
67 (format-time-string notes-file-form epoch)
68 (if tag "#* " "")
69 tag)))
70
71 (provide 'notes-aux)
72 ;;; notes-aux.el ends here