public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Brian Inglis <Brian.Inglis@SystematicSw.ab.ca>
To: cygwin@cygwin.com
Subject: Re: Cygwin strptime() is missing "%s" which strftime() has
Date: Wed, 30 Aug 2017 00:25:00 -0000	[thread overview]
Message-ID: <61717e28-cfcb-ca9d-a20d-eb54c31a3c4a@SystematicSw.ab.ca> (raw)
In-Reply-To: <f31c3fdb-7e17-0238-4bb2-a0e6c8dd6b5e@SystematicSw.ab.ca>

On 2017-07-25 10:47, Brian Inglis wrote:
> On 2017-07-24 17:18, Kaz Kylheku wrote:
>> On 24.07.2017 15:51, Brian Inglis wrote:
>>> On 2017-07-24 15:02, Hans-Bernhard Bröker wrote:
>>>> Am 24.07.2017 um 04:09 schrieb Lavrentiev, Anton (NIH/NLM/NCBI) [C]:
>>>>
>>>>> rather it's a question about portability of code that
>>>>> uses %s for both functions and expects it to work unchanged in the
>>>>> Cygwin environment.
>>>>
>>>> And the answer to that question is: such code _is_not_portable_, and therefore
>>>> that expectation is wrong.
>>>>
>>>> If that code claims to be portable, then its use of %s in either of those
>>>> functions constitutes a _bug_.
>>>>
>>>> In the old days there was a well-known fallacy known by the slogan "all the
>>>> world's a VAX."  Nowadays it appears to have been replaced by an equally
>>>> wide-spread, and equally incorrect belief that all the world is Linux.  Well,
>>>> it's not.  Not even the whole Un*x world is Linux.
>>>
>>> Rather "all the world's a GNU" i.e. glibc, but there's also BSD libc, RTEMS and
>>> Cygwin newlib, and others.
>>
>> Since the utilities depend on the C library functionality for strptime and
>> strftime, even having GNU utilities won't help.
>>
>> There doesn't appear any nice way in POSIX shell scripting to have access to
>> the seconds since the Epoch.
>>
>> If you have GNU Awk, it has some time functions like mktime, which don't rely
>> on any C library extensions.
> 
> If you have GNU gawk you probably also have GNU coreutils date, which supports
> +%s for output and -d@nnnnnnnnnn for input, whether or not the system strftime
> and strptime support %s.
> 
> GNU coreutils date with shell arithmetic is adequate to support shell script
> conversions between time scales with different epochs e.g. Julian Day, Modified
> Julian Day, NTP, Unix, GPS, and calculations using those values.
> 
> Awk, JS, or some other language supporting FP is required for subsecond or
> fractional day accuracy with convenient output.

Patch in latest test release provides %s support for strptime(3) used by
strptime(1).
Another strptime(3) patch was just submitted to fix %F handling.
More newlib time patches coming to fix handling years around INT_MAX and high
values of time_t.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

  reply	other threads:[~2017-08-30  0:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-24  9:21 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2017-07-24 10:53 ` Corinna Vinschen
2017-07-24 21:02 ` Kaz Kylheku
2017-07-24 21:28 ` Hans-Bernhard Bröker
2017-07-24 23:18   ` Brian Inglis
2017-07-24 23:31     ` Kaz Kylheku
2017-07-25 18:27       ` Brian Inglis
2017-08-30  0:25         ` Brian Inglis [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-07-24 21:48 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2017-07-24 22:12 ` Eric Blake
2017-07-24 22:51   ` Brian Inglis
2017-07-24 19:51 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2017-07-24 13:54 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2017-07-24 17:02 ` Eric Blake
2017-07-23 11:38 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2017-07-23 21:18 ` Kaz Kylheku

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=61717e28-cfcb-ca9d-a20d-eb54c31a3c4a@SystematicSw.ab.ca \
    --to=brian.inglis@systematicsw.ab.ca \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).