Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Nov 2019 17:28:28 +0100 (CET)
From:      =?UTF-8?Q?Trond_Endrest=C3=B8l?= <trond.endrestol@ximalas.info>
To:        freebsd-questions@freebsd.org
Subject:   Re: How to convert svn repository change date to epoch timestamp?
Message-ID:  <alpine.BSF.2.21.99999.352.1911031724370.5571@enterprise.ximalas.info>
In-Reply-To: <trinity-0e118d1a-6b7c-4c5e-a0b8-2b6fceb1e713-1572782605441@3c-app-gmx-bs36>
References:  <trinity-0e118d1a-6b7c-4c5e-a0b8-2b6fceb1e713-1572782605441@3c-app-gmx-bs36>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 3 Nov 2019 13:03+0100, mj-mailinglist@gmx.de wrote:

> I am trying to convert the output of this command
> 
> svnlite info --show-item last-changed-date /usr/src/
> 
> to an epoch timestamp with base tools.
> 
> The output looks like this: 2019-11-03T07:11:09.005639Z
> 
> The date man page gives this example for converting dates:
> 
> date -j -f "%a %b %d %T %Z %Y" "`date`" "+%s"
> (maybe add the info, that you have to use LC_TIME=C for this example to work)
> 
> I came up with this date format string "%Y-%m-%dT%H:%M:%SZ" but this
> lacks the fractions part of the seconds.
> 
> Is this possible with the tools in base?
> 
> Or maybe i could chop of the second-fractions?

Try this:

date -juf "%FT%TZ" `svnlite info --no-newline --show-item last-changed-date /usr/src | sed 's/\.[0-9]*Z$/Z/'` "+%s"

-- 
Trond.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.21.99999.352.1911031724370.5571>