[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tomelr 91800b26b8 21/84: feat: Recognize RFC 3339 forma
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tomelr 91800b26b8 21/84: feat: Recognize RFC 3339 formatted date-time + offset |
Date: |
Tue, 3 May 2022 09:58:09 -0400 (EDT) |
branch: externals/tomelr
commit 91800b26b8bff6b89fce887fbcadb9e956f412dd
Author: Kaushal Modi <kaushal.modi@gmail.com>
Commit: Kaushal Modi <kaushal.modi@gmail.com>
feat: Recognize RFC 3339 formatted date-time + offset
---
README.org | 17 ++++++++++++-----
test/tscalar.el | 14 ++++++++++++++
tomelr.el | 22 ++++++++++------------
3 files changed, 36 insertions(+), 17 deletions(-)
diff --git a/README.org b/README.org
index 757e641f7b..5f1db7d305 100644
--- a/README.org
+++ b/README.org
@@ -18,15 +18,15 @@ the Emacs core library
[[https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/j
It will then be gradually refactored so that it meets the
specification defined below.
-* Library Completion Status [0/6]
-- [-] Scalar
+* Library Completion Status [1/7]
+- [X] Scalar
- [X] Boolean
- [X] Integer
- [X] Float
- [X] String
- [X] Date
- - [ ] Date + Time with Offset
- - [ ] Nil
+ - [X] Date + Time with Offset
+- [ ] Nil
- [ ] Arrays
- [ ] Array of Arrays
- [ ] Tables
@@ -208,7 +208,8 @@ ld1 = 1979-05-27
: {
: "ld1": "1979-05-27"
: }
-*** Date + Time with Offset
+*** DONE Date + Time with Offset
+CLOSED: [2022-04-28 Thu 22:55]
https://toml.io/en/v1.0.0#offset-date-time
**** S-expression
#+begin_src emacs-lisp :eval no :noweb-ref scalar-odt
@@ -217,6 +218,12 @@ https://toml.io/en/v1.0.0#offset-date-time
(odt3 . "1979-05-27T00:32:00.999999-07:00"))
#+end_src
**** TOML
+#+begin_src emacs-lisp :noweb yes :exports results :wrap src toml
+(tomelr-encode
+ <<scalar-odt>>)
+#+end_src
+
+#+RESULTS:
#+begin_src toml
odt1 = 1979-05-27T07:32:00Z
odt2 = 1979-05-27T00:32:00-07:00
diff --git a/test/tscalar.el b/test/tscalar.el
index 12ebb081fa..bddb946414 100644
--- a/test/tscalar.el
+++ b/test/tscalar.el
@@ -99,6 +99,20 @@ Violets are blue\"\"\""
(push (tomelr-encode el) out))
(should (equal ref (nreverse out)))))
+;;;; Scalar - Date + Time
+(ert-deftest test-scalar-date-time ()
+ (let ((inp '(((odt1 . "1979-05-27T07:32:00Z"))
+ ((odt2 . "1979-05-27 07:32:00Z"))
+ ((odt3 . "1979-05-27T00:32:00-07:00"))
+ ((odt4 . "1979-05-27T00:32:00.999999+04:00"))))
+ (ref '("odt1 = 1979-05-27T07:32:00Z"
+ "odt2 = 1979-05-27 07:32:00Z"
+ "odt3 = 1979-05-27T00:32:00-07:00"
+ "odt4 = 1979-05-27T00:32:00.999999+04:00"))
+ out)
+ (dolist (el inp)
+ (push (tomelr-encode el) out))
+ (should (equal ref (nreverse out)))))
(provide 'tscalar)
diff --git a/tomelr.el b/tomelr.el
index 28cf4b242d..341417f53c 100644
--- a/tomelr.el
+++ b/tomelr.el
@@ -153,10 +153,11 @@ If TRIM-INIT-CHARS is positive, those many initial
characters
of the STRING are not inserted.
Return the same STRING passed as input."
+ ;; (message "[tomelr--print-string DBG] string = `%s'" string)
(let ((special-chars '((?b . ?\b) ;U+0008
(?f . ?\f) ;U+000C
(?\\ . ?\\)))
- special-chars-re
+ (special-chars-re (rx (in ?\" ?\\ cntrl ?\u007F))) ;cntrl is same as
(?\u0000 . ?\u001F)
begin-q end-q)
(cond
((string-match-p tomelr--date-time-regexp string)) ;RFC 3339 formatted
date-time with offset
@@ -176,26 +177,23 @@ Return the same STRING passed as input."
(setq begin-q "\"\"\"\n")
(setq end-q "\"\"\""))
(t ;Basic quotation "STRING"
- (setq special-chars-re (rx (in ?\" ?\\ cntrl ?\u007F))) ;cntrl is same
as (?\u0000 . ?\u001F)
(push '(?\" . ?\") special-chars)
(push '(?t . ?\t) special-chars) ;U+0009
(push '(?n . ?\n) special-chars) ;U+000A
(push '(?r . ?\r) special-chars) ;U+000D
(setq begin-q "\"")
(setq end-q begin-q)))
- ;; (message "[tomelr--print-string DBG] string = `%s'" string)
(and begin-q (insert begin-q))
(goto-char (prog1 (point) (princ string)))
(and trim-init-chars (delete-char trim-init-chars))
- (when special-chars-re
- (while (re-search-forward special-chars-re nil :noerror)
- (let ((char (preceding-char)))
- (delete-char -1)
- (insert ?\\ (or
- ;; Escape special characters
- (car (rassq char special-chars))
- ;; Fallback: UCS code point in \uNNNN form.
- (format "u%04x" char))))))
+ (while (re-search-forward special-chars-re nil :noerror)
+ (let ((char (preceding-char)))
+ (delete-char -1)
+ (insert ?\\ (or
+ ;; Escape special characters
+ (car (rassq char special-chars))
+ ;; Fallback: UCS code point in \uNNNN form.
+ (format "u%04x" char)))))
(and end-q (insert end-q))
string))
- [elpa] externals/tomelr 7d8d41f15b 19/84: feat: Encode to multi-line TOML string automatically, (continued)
- [elpa] externals/tomelr 7d8d41f15b 19/84: feat: Encode to multi-line TOML string automatically, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 0ba5f2ff69 24/84: chore(readme): Move mixed type array example to the 'medley' example, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr ca9245038a 35/84: fix: Attempt to make tomelr--toml-table-p more robust, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 000067cf7d 14/84: chore(readme): Update, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 69217d47a6 22/84: feat: Skip converting keys whose values are nil, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr af40c0b40f 11/84: fix: Require subr-x for older Emacs versions, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 060c38b934 16/84: chore(readme): Limit up to 3 levels of headings for Org exports, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 20bf9e6c54 12/84: chore(doc): Add GHA and license badges, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr f37841cc78 25/84: test: Add test for TOML Array of Arrays, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr cedb75df72 29/84: feat: Support basic TOML tables, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 91800b26b8 21/84: feat: Recognize RFC 3339 formatted date-time + offset,
ELPA Syncer <=
- [elpa] externals/tomelr 83e924559e 13/84: chore(doc): Fix typo, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 98c9b8c1fc 26/84: fix: Use `=` and `length` separately instead of `length=`, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr c0962ba15f 33/84: fix: Don't run plist to TOML conversion test on emacs 26.3 and older, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 3c068fb9d9 34/84: refactor: Move TOML Table detection logic to a separate fn, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr ad8366d904 36/84: feat: Support basic TOML Table Arrays, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 55fefb0fa8 40/84: doc: Add few links, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 38160ef271 41/84: fix: Stricter condition before starting TOML table array check, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr a7b3a57037 48/84: feat: Make a very basic nested array of TTA work, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 3aa4dc1dbd 54/84: chore: Add Package-Requires and other info in the header comment, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr f3b6951cfe 53/84: doc: Add note that the scalars need to be earlier in the order, ELPA Syncer, 2022/05/03