How to convert svn repository change date to epoch timestamp?
Per Hedeland
per at hedeland.org
Sun Nov 3 18:02:35 UTC 2019
On 2019-11-03 17:33, Trond Endrestøl wrote:
> On Sun, 3 Nov 2019 17:28+0100, Trond Endrestøl wrote:
>
>> date -juf "%FT%TZ" `svnlite info --no-newline --show-item last-changed-date /usr/src | sed 's/\.[0-9]*Z$/Z/'` "+%s"
>
> Even simpler:
>
> date -juf "%FT%T" `svnlite info --no-newline --show-item last-changed-date /usr/src | sed 's/\.[0-9]*Z$//'` "+%s"
Simpler still, if you don't mind the warning:
$ date -juf "%FT%T" `svnlite info --show-item last-changed-date /usr/ports` +%s
Warning: Ignoring 8 extraneous characters in date string (.012563Z)
1572745647
But I have to admit that GNU 'date', mentioned in another post, really
beats FreeBSD 'date' here, since it can parse the ISO 8601 format,
including the fractional second and the "Z" a.k.a. UTC time zone,
without even being given a format spec:
$ uname -a
Linux ...
$ date -d 2019-11-03T07:11:09.005639Z +%s.%N
1572765069.005639000
Alas, it is not among "the tools in base", and in the general case, I
guess there may be "reasonable doubt" as to whether its parsing is
actually correct (it isn't *possible* to give a format spec). But for
a correctly formed 8601 date/time, it should absolutely be OK.
--Per
More information about the freebsd-questions
mailing list