unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tino Calancha <f92capac@gmail.com>
To: Nicolas Richard <youngfrog@members.fsf.org>
Cc: Tino Calancha <f92capac@gmail.com>, 21229@debbugs.gnu.org
Subject: bug#21229: 24.5; parse-time-string ignore PM/AM
Date: Tue, 11 Aug 2015 19:37:00 +0900 (JST)	[thread overview]
Message-ID: <alpine.LRH.2.20.1508111933430.16604@calancha-ilc.kek.jp> (raw)
In-Reply-To: <87oaieb4y0.fsf@members.fsf.org>

[-- Attachment #1: Type: text/plain, Size: 1376 bytes --]



I attached a patch showing how i am dealing temporally with this
AM/PM issue.

We have rule for iso 8601:
"%Y-%m-%d"

It should be possible to add support for:
"%m/%d/%y"

(similarly as we have several rules for HH:MM:SS)

I guess its natural to support both.

Tino



On Tue, 11 Aug 2015, Nicolas Richard wrote:

> Tino Calancha <f92capac@gmail.com> writes:
>> Maybe  parsing "%c" looks too ambitius for the
>> freedoom of the output format.
>
> Also FWIW, parse-time-string won't parse (format-time-string "%c"
> (current-time)) correctly in many non-english locales because it won't
> recognize the month names.
>
> In my french setup:
> (format-time-string "%c" (current-time)) => "mar. 11 août 2015 07:34:35 CEST"
>
> "mar" stands for "mardi" (= Tuesday), but will be understood as "March" :
> (parse-time-string "mar. 11 août 2015 07:34:35 CEST") => (35 34 7 11 3 2015 nil nil nil)
>
>> We may need something like:
>>
>> once you find "am" "pm" look the token: "HH:MM:SS" and ask:
>>
>> when "pm" and HH < 12: HH ---> HH + 12
>
> Currently parse-time-string works with rules (they are found in
> parse-time-rules), each setting one element of a (SEC MIN HOUR DAY MON
> YEAR DOW DST TZ) list. When one such element is set, parse-time-string
> won't modify it anymore. So we need a small change in the design here if
> we want to take PM into account.
>
> -- 
> Nico
>

[-- Attachment #2: Type: text/plain, Size: 826 bytes --]

--- parse-time.el	2015-08-11 18:06:46.895638495 +0900
+++ parse-time_1.el	2015-08-11 19:19:20.855001776 +0900
@@ -182,7 +182,10 @@
 The values are identical to those of `decode-time', but any values that are
 unknown are returned as nil."
   (let ((time (list nil nil nil nil nil nil nil nil nil))
-	(temp (parse-time-tokenize (downcase string))))
+		(temp (parse-time-tokenize (downcase string)))
+		(has-pm nil))
+	(when (member "pm" temp)
+	  (setq has-pm t))
     (while temp
       (let ((parse-time-elt (pop temp))
 	    (rules parse-time-rules)
@@ -216,6 +219,8 @@
 				       (funcall this)))
 				 parse-time-val)))
 		  (rplaca (nthcdr (pop slots) time) new-val))))))))
+	(when (and has-pm (< (nth 2 time) 12))
+	  (setf (nth 2 time) (+ (nth 2 time) 12)))
     time))
 
 (provide 'parse-time)

  reply	other threads:[~2015-08-11 10:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-10  8:19 bug#21229: 24.5; parse-time-string ignore PM/AM Tino Calancha
2015-08-10 17:29 ` Eli Zaretskii
2015-08-10 17:35   ` Tino Calancha
2015-08-10 17:46     ` Eli Zaretskii
2015-08-11  2:36       ` Tino Calancha
2015-08-11  8:32         ` Nicolas Richard
2015-08-11 10:37           ` Tino Calancha [this message]
2015-08-11 10:40             ` Andreas Schwab
2015-08-11 10:52               ` Tino Calancha
2015-08-11 11:00                 ` Andreas Schwab
2015-08-11 11:47                   ` Tino Calancha
2015-08-11 16:05               ` Stefan Monnier
2015-08-12  5:45                 ` Tino Calancha
2015-08-12 12:39                   ` Eli Zaretskii
2015-08-12 12:46                     ` Tino Calancha
2015-08-12 12:41                   ` Nicolas Richard
2020-08-24 18:35     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LRH.2.20.1508111933430.16604@calancha-ilc.kek.jp \
    --to=f92capac@gmail.com \
    --cc=21229@debbugs.gnu.org \
    --cc=youngfrog@members.fsf.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).