Aw: Re: How to convert svn repository change date to epoch timestamp?
mj-mailinglist at gmx.de
mj-mailinglist at gmx.de
Sun Nov 10 10:26:42 UTC 2019
>>> 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
Thanks everyone,
i am going with the sed part. Is this the only place in FreeBSD where the ISO 8601 format including fractions of seconds is used?
There was a patch for adding it as an option to syslogd (https://reviews.freebsd.org/D14918), but that was not commited
Wouldn't it be best, if date is extended to handle the fraction part officialy? I looked at the code, but have no idea where to start.
--
Martin
More information about the freebsd-questions
mailing list