[buildd-tools-devel] Bug#834736: Bug#834736: sbuild: Use basic format for ISO 8601 timestamps (for build logs filenames)

Johannes Schauer josch at debian.org
Fri Aug 19 04:26:29 UTC 2016


Hi,

Quoting Santiago Vila (2016-08-18 19:31:30)
> Try doing that in standard AWK without those fancy time-handling functions
> :-)
> 
> For the basic format it would be something like this:
> 
> date=substr(stamp,1,8)
> time=substr(stamp,10,6)
> 
> I leave the extended format as an exercise for the reader.

challenge accepted! To parse the current format just with shell tool, you would
do:

	TZ=0 date -d'2016-08-18T17:09:36Z' +%s

You are welcome. I would say that this is even simpler than your awk solution
as you don't even need to hardcode any offsets and immediately even get the
epoch for easy comparison.

> It is in this sense that I said "easier to parse".

Really? Now lets try to parse the basic format:

	TZ=0 date -d'20160818T170936Z' +%s
date: invalid date ‘20160818T170936Z’

Figuring out how to parse the basic format with `date` is left as an exercise
to the reader. ;)

> Also: The extended format makes the filename a little bit longer and a little
> bit more difficult to handle, as the ":" has to be escaped.

Why does the colon have to be escaped?

Please point me to the part of the POSIX shell documentation (or whatever other
language you are using) where you have to escape the colon. Try:

echo :

Works fine here without any escaping.

> In either case: Nobody asked for a way to specify the filename format in a
> flexible way?

Correct, nobody did.

> For example: If I wanted an integer suffix meaning the number of seconds
> since the epoch, how I would do that?

See my `date` based solution to parse the filename above.

Thanks!

cheers, josch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: signature
URL: <http://lists.alioth.debian.org/pipermail/buildd-tools-devel/attachments/20160819/b7ca1a10/attachment.sig>


More information about the Buildd-tools-devel mailing list