This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cygwin strptime() is missing "%s" which strftime() has

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.

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

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]