[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r111182: * lisp/calc/calc.el (calc-st
From: |
Jay Belanger |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r111182: * lisp/calc/calc.el (calc-standard-date-formats): Add more date |
Date: |
Mon, 10 Dec 2012 20:29:21 -0600 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 111182
committer: Jay Belanger <address@hidden>
branch nick: trunk
timestamp: Mon 2012-12-10 20:29:21 -0600
message:
* lisp/calc/calc.el (calc-standard-date-formats): Add more date
formats.
* lisp/calc/calc-forms.el (math-parse-iso-date): New function.
(math-parse-date): Use `math-parse-iso-date' when appropriate.
(math-parse-iso-date-validate): Add extra error checking.
(calc-date-notation): Add ability to access new date formats.
modified:
lisp/ChangeLog
lisp/calc/calc-forms.el
lisp/calc/calc.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-12-10 21:26:13 +0000
+++ b/lisp/ChangeLog 2012-12-11 02:29:21 +0000
@@ -1,3 +1,12 @@
+2012-12-11 Jay Belanger <address@hidden>
+
+ * calc/calc.el (calc-standard-date-formats): Add more date
+ formats.
+ * calc/calc-forms.el (math-parse-iso-date): New function.
+ (math-parse-date): Use `math-parse-iso-date' when appropriate.
+ (math-parse-iso-date-validate): Add extra error checking.
+ (calc-date-notation): Add ability to access new date formats.
+
2012-12-10 Stefan Monnier <address@hidden>
* hi-lock.el (hi-lock--regexps-at-point): Fix boundary case for
=== modified file 'lisp/calc/calc-forms.el'
--- a/lisp/calc/calc-forms.el 2012-12-03 04:46:49 +0000
+++ b/lisp/calc/calc-forms.el 2012-12-11 02:29:21 +0000
@@ -82,13 +82,13 @@
(calc-wrapper
(if (string-match-p "\\`\\s-*\\'" fmt)
(setq fmt "1"))
- (if (string-match "\\` *[0-9] *\\'" fmt)
+ (if (string-match "\\` \\(*[0-9]\\|10\\|11\\) *\\'" fmt)
(setq fmt (nth (string-to-number fmt) calc-standard-date-formats)))
(or (string-match "[a-zA-Z]" fmt)
(error "Bad date format specifier"))
(and arg
(>= (setq arg (prefix-numeric-value arg)) 0)
- (<= arg 9)
+ (<= arg 11)
(setq calc-standard-date-formats
(copy-sequence calc-standard-date-formats))
(setcar (nthcdr arg calc-standard-date-formats) fmt))
@@ -918,6 +918,8 @@
(catch 'syntax
(or (math-parse-standard-date math-pd-str t)
(math-parse-standard-date math-pd-str nil)
+ (and (or (memq 'IYYY calc-date-format) (memq 'Iww calc-date-format))
+ (math-parse-iso-date math-pd-str))
(and (string-match
"\\`[^-+/0-9a-zA-Z]*\\([-+]?[0-9]+\\.?[0-9]*\\([eE][-+]?[0-9]+\\)?\\)[^-+/0-9a-zA-Z]*\\'"
math-pd-str)
(list 'date (math-read-number (math-match-substring math-pd-str
1))))
(let ((case-fold-search t)
@@ -1085,6 +1087,8 @@
(defun math-parse-iso-date-validate (isoyear isoweek isoweekday hour minute
second)
(if (or (< isoweek 1) (> isoweek 53))
(throw 'syntax "Week value is out of range"))
+ (if (or (< isoweekday 1) (> isoweekday 7))
+ (throw 'syntax "Weekday value is out of range"))
(and hour
(progn
(if (or (< hour 0) (> hour 23))
@@ -1290,6 +1294,31 @@
(setq day (math-add day (1- yearday))))
day))))))
+(defun math-parse-iso-date (math-pd-str)
+ "Parse MATH-PD-STR as an ISO week date, or return nil."
+ (let ((case-fold-search t)
+ (isoyear nil) (isoweek nil) (isoweekday nil)
+ (hour nil) (minute nil) (second nil))
+ ;; Extract the time, if any.
+ (if (string-match
"T[^0-9]*\\([0-9][0-9]\\)[^0-9]*\\([0-9][0-9]\\)?[^0-9]*\\([0-9][0-9]\\(\\.[0-9]+\\)?\\)?"
math-pd-str)
+ (progn
+ (setq hour (string-to-number (math-match-substring math-pd-str 1))
+ minute (math-match-substring math-pd-str 2)
+ second (math-match-substring math-pd-str 3)
+ math-pd-str (substring math-pd-str 0 (match-beginning 0)))
+ (if (equal minute "")
+ (setq minute 0)
+ (setq minute (string-to-number minute)))
+ (if (equal second "")
+ (setq second 0)
+ (setq second (math-read-number second)))))
+ ;; Next, the year, week and weekday
+ (if (string-match
"\\(-?[0-9]*\\)[^0-9]*W\\([0-9][0-9]\\)[^0-9]*\\([0-9]\\)[^0-9]*\\'"
math-pd-str)
+ (progn
+ (setq isoyear (string-to-number (math-match-substring math-pd-str 1))
+ isoweek (string-to-number (math-match-substring math-pd-str 2))
+ isoweekday (string-to-number (math-match-substring math-pd-str
3)))
+ (math-parse-iso-date-validate isoyear isoweek isoweekday hour minute
second)))))
(defun calcFunc-now (&optional zone)
(let ((date (let ((calc-date-format nil))
=== modified file 'lisp/calc/calc.el'
--- a/lisp/calc/calc.el 2012-11-22 08:09:03 +0000
+++ b/lisp/calc/calc.el 2012-12-11 02:29:21 +0000
@@ -787,7 +787,9 @@
"M-D-Y< H:mm:SSpp>"
"D-M-Y< h:mm:SS>"
"j<, h:mm:SS>"
- "YYddd< hh:mm:ss>"))
+ "YYddd< hh:mm:ss>"
+ "ZYYY-MM-DD Www< hh:mm>"
+ "IYYY-Iww-w< Thh:mm:ss>"))
(defcalcmodevar calc-autorange-units nil
"If non-nil, automatically set unit prefixes to keep units in a reasonable
range.")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r111182: * lisp/calc/calc.el (calc-standard-date-formats): Add more date,
Jay Belanger <=