From owner-freebsd-questions@freebsd.org Sun Nov 3 18:02:35 2019 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A65FF17E45F for ; Sun, 3 Nov 2019 18:02:35 +0000 (UTC) (envelope-from per@hedeland.org) Received: from mailout.easydns.com (mailout.easydns.com [64.68.202.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 475kKk3t95z3DkC for ; Sun, 3 Nov 2019 18:02:34 +0000 (UTC) (envelope-from per@hedeland.org) Received: from localhost (localhost [127.0.0.1]) by mailout.easydns.com (Postfix) with ESMTP id 19E72A047D for ; Sun, 3 Nov 2019 18:02:33 +0000 (UTC) Received: from mailout.easydns.com ([127.0.0.1]) by localhost (emo13-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CtTBnImSq_ye for ; Sun, 3 Nov 2019 18:02:33 +0000 (UTC) Received: from hedeland.org (81-228-157-209-no289.tbcn.telia.com [81.228.157.209]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mailout.easydns.com (Postfix) with ESMTPSA id D2A59A0315 for ; Sun, 3 Nov 2019 18:02:32 +0000 (UTC) Received: from pluto.hedeland.org (pluto.hedeland.org [10.1.1.5]) by tellus.hedeland.org (8.15.2/8.15.2) with ESMTPS id xA3I2UZR026598 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO) for ; Sun, 3 Nov 2019 19:02:30 +0100 (CET) (envelope-from per@hedeland.org) Subject: Re: How to convert svn repository change date to epoch timestamp? To: freebsd-questions@freebsd.org References: From: Per Hedeland Message-ID: Date: Sun, 3 Nov 2019 19:02:30 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 475kKk3t95z3DkC X-Spamd-Bar: ++++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of per@hedeland.org has no SPF policy when checking 64.68.202.10) smtp.mailfrom=per@hedeland.org X-Spamd-Result: default: False [4.15 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; RWL_MAILSPIKE_POSSIBLE(0.00)[10.202.68.64.rep.mailspike.net : 127.0.0.17]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; IP_SCORE(0.56)[ip: (0.97), ipnet: 64.68.200.0/22(0.16), asn: 16686(1.77), country: CA(-0.09)]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; TO_DN_NONE(0.00)[]; AUTH_NA(1.00)[]; RCPT_COUNT_ONE(0.00)[1]; RECEIVED_SPAMHAUS_PBL(0.00)[209.157.228.81.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; MIME_TRACE(0.00)[0:+]; NEURAL_SPAM_MEDIUM(0.82)[0.822,0]; NEURAL_SPAM_LONG(0.97)[0.969,0]; DMARC_NA(0.00)[hedeland.org]; R_SPF_NA(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[10.202.68.64.list.dnswl.org : 127.0.5.1]; R_DKIM_NA(0.00)[]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:16686, ipnet:64.68.200.0/22, country:CA]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; FROM_EQ_ENVFROM(0.00)[] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Nov 2019 18:02:35 -0000 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