Date: Sun, 3 Nov 2019 19:02:30 +0100 From: Per Hedeland <per@hedeland.org> To: freebsd-questions@freebsd.org Subject: Re: How to convert svn repository change date to epoch timestamp? Message-ID: <e1a46469-254b-cefe-3f7e-a200f0f8736b@hedeland.org> In-Reply-To: <alpine.BSF.2.21.99999.352.1911031732260.5571@enterprise.ximalas.info> References: <trinity-0e118d1a-6b7c-4c5e-a0b8-2b6fceb1e713-1572782605441@3c-app-gmx-bs36> <alpine.BSF.2.21.99999.352.1911031724370.5571@enterprise.ximalas.info> <alpine.BSF.2.21.99999.352.1911031732260.5571@enterprise.ximalas.info>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?e1a46469-254b-cefe-3f7e-a200f0f8736b>