all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#25112: 24.5; function to encode time from time string
@ 2016-12-04 20:56 Drew Adams
  2016-12-04 21:50 ` Drew Adams
  2016-12-05 16:08 ` Eli Zaretskii
  0 siblings, 2 replies; 4+ messages in thread
From: Drew Adams @ 2016-12-04 20:56 UTC (permalink / raw
  To: 25112

Enhancement request: Please add a function that accepts a time string
and a format spec (to interpret the time string), and returns a time
value that represents the same time.

I could not find such a function mentioned in the manuals.  I came
across a need for such a thing when wanting to convert the :time entry
of an Eww "bookmark" to a (SEC-HIGH SEC-LOW MICROSEC PICOSEC) list such
as is returned by `current-time', for use in an ordinary Emacs bookmark.

(I have no idea why Eww uses a string to record the time, as there is
little you can do with it besides read it as a human.  But it does.)

(I have no idea why Eww uses its own, incompatible form of "bookmarks".
But it does.  And so does Org.)


In GNU Emacs 24.5.1 (i686-pc-mingw32)
 of 2015-04-11 on LEG570
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/usr --host=i686-pc-mingw32'





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#25112: 24.5; function to encode time from time string
  2016-12-04 20:56 bug#25112: 24.5; function to encode time from time string Drew Adams
@ 2016-12-04 21:50 ` Drew Adams
  2016-12-05 16:08 ` Eli Zaretskii
  1 sibling, 0 replies; 4+ messages in thread
From: Drew Adams @ 2016-12-04 21:50 UTC (permalink / raw
  To: 25112

FYI, I just now came across this library on Emacs Wiki:
https://www.emacswiki.org/emacs/strptime.el

It seems to have something similar to the requested enhancement.
It is not something that I can use, and it is no replacement
for the enhancement, but it might help.  The copyright for it
is by A. Aichner of XEmacs.

The library description is this:

 partial implementation of POSIX date and time parsing
 Implemented (partially, specifically without locale support) according to
 http://www.opengroup.org/onlinepubs/009695399/functions/strptime.html

The main function (command) it provides is this:

(defun strptime (time format &optional extended)
  "Return a nine element list of TIME, parsed according to FORMAT..."





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#25112: 24.5; function to encode time from time string
  2016-12-04 20:56 bug#25112: 24.5; function to encode time from time string Drew Adams
  2016-12-04 21:50 ` Drew Adams
@ 2016-12-05 16:08 ` Eli Zaretskii
  1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2016-12-05 16:08 UTC (permalink / raw
  To: Drew Adams; +Cc: 25112

> Date: Sun, 4 Dec 2016 12:56:47 -0800 (PST)
> From: Drew Adams <drew.adams@oracle.com>
> 
> Enhancement request: Please add a function that accepts a time string
> and a format spec (to interpret the time string), and returns a time
> value that represents the same time.

I believe you want either date-to-time or parse-time-string (the
former is just a thin wrapper around the latter).  date-to-time is
described in the ELisp manual.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#25112: 24.5; function to encode time from time string
       [not found] ` <<83vauyjr3g.fsf@gnu.org>
@ 2016-12-05 21:49   ` Drew Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2016-12-05 21:49 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: 25112

> > Enhancement request: Please add a function that accepts a time
> > string and a format spec (to interpret the time string), and
> > returns a time value that represents the same time.
> 
> I believe you want either date-to-time or parse-time-string (the
> former is just a thin wrapper around the latter).  date-to-time is
> described in the ELisp manual.

Sheesh.  Dunno how I missed `date-to-time' in the manual.  I read
the 3 nodes about dates & times, but clearly I didn't read them
well enough.

Maybe it would help to mention this direction of conversion after
the second paragraph of node `Time of Day', with a cross-reference?

And maybe the node named `Time Conversion' should mention something
about conversion both directions between strings and times, with
cross-references?

Anyway, `date-to-time' does what I want (though it seems to give
only a 2-element list, at least in the cases I've tried).

Its name does NOT seem very good, though.  Among other things,
either a date or a time can be represented as either a list or
a string - neither is inherently only one or the other.

It might help to say something like:

 (current-time-string (date-to-time date-time-string)) =
 date-time-string

and

 (date-to-time (current-time-string date-time-list)) =
 date-time-list

Or if these are not always strictly true then at least point out
that this is the general idea.

E.g.,

 (current-time-string (date-to-time "Sun Nov 27 16:38:38 2016")) =
 "Sun Nov 27 16:38:38 2016"

 (date-to-time (current-time-string '(22587 31886))) = (22587 31886)

I will close this bug, in any case.  Thx.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-12-05 21:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-04 20:56 bug#25112: 24.5; function to encode time from time string Drew Adams
2016-12-04 21:50 ` Drew Adams
2016-12-05 16:08 ` Eli Zaretskii
     [not found] <<5b95d9b8-3281-40da-872d-1a98b8a3d1fa@default>
     [not found] ` <<83vauyjr3g.fsf@gnu.org>
2016-12-05 21:49   ` Drew Adams

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.