20 Commits
Author SHA1 Message Date
kristapsdz 4d7a2e049f Don't use XWARNX. 2020-07-17 10:07:37 +00:00
kristapsdz cace5ea73c Optimise the year calculation. This was doing a linear scan of each year,
accumulating the days per year.  Convert it to doing a linear scan til the
400 year barrier, then consuming the intervening eras all at once.  This
makes the computation effectively constant-time.  (It can be improved, by also
jumping forward in centennials, but I wanted to have the easiest-to-read
version first.)
2020-05-11 10:54:22 +00:00
kristapsdz c803276c92 Don't use "struct tm" conventions for this function. 2020-05-10 16:23:35 +00:00
kristapsdz 2bacfb3e4d Switch completely to using int64_t internally, with only khttp_epoch2tms being
the only non-int64_t version.  This catches corner cases where int-valued years
will overflow.  While here, don't using the internal mktime-style conversion
code, instead preventing input values from having bad components.

This also adds khttp_epoch2datetime, which symmetrises khttp_datetime2epoch.
2020-05-10 15:20:04 +00:00
kristapsdz 1b4efc5e13 Don't use strftime at all, which doesn't handle 5-digit years on Solaris. 2020-05-10 09:07:53 +00:00
kristapsdz 9ef6206e23 Don't use time_t at all, as it will convert from the 64 bits for non-64 bit
time machines.
2020-05-06 21:56:05 +00:00
kristapsdz 16cdd3710c Use newlib's gmtime as well. This accepts 64-bit time values unlike Solaris,
which still has 32-bit time, and some Linux.  This allows kcgi to be totally
64-bit time friendly.
2020-05-06 19:17:30 +00:00
kristapsdz 9bcd5fb595 INT_MAX is in limits.h, not sys/param.h. 2020-05-06 17:32:09 +00:00
kristapsdz 5e28bbe0ac Code docs and tweak release notes. 2020-05-06 13:39:16 +00:00
kristapsdz 69f195c684 Use an internal mktime/timegm based upon newlib's code. This is because FreeBSD
doesn't handle year values before 1900, which is ridiculous, so a portable
version is necessary.
2020-05-06 13:26:33 +00:00
kristapsdz 6a4da3bde8 Provide safer, more meaningful datetime conversion functions. These use
timegm(3) as the underlying mechanism instead of relying on hand-rolled functions.
They improve upon timegm(3) in not having ambiguous return values.
Also add regression tests for all new functions.
2020-05-05 10:26:55 +00:00
kristapsdz 35d192dfec Reconstitute kutil_epoch2str, kutil_epoch2utcstr, kutil_epoch2tmvals, and
KUTIL_EPOCH2TM as khttp_epoch2str, khttp_epoch2ustr, khttp_epoch2tms, and
KHTTP_EPOCH2TM, respectively.  Internally, these now use gmtime() instead
of the legacy hand-rolled system.  They cover a significantly broader range
of time (including negative time values), properly truncate strings in the
the 2str and 2ustr case, and properly handle NULL or zero-length input.
2020-04-24 12:40:29 +00:00
kristapsdz be5bc1c712 Copyright year. 2018-01-04 05:00:32 +00:00
kristapsdz f7d5576af6 Introduce functions for validating broken-down dates and times. 2018-01-04 04:57:36 +00:00
kristapsdz 685abdeced Full switch to oconfigure instead of current system, so remove all of the
test and compat files.  These are now in tests.c and compats.c, and driven
by the configure script.   Also remove the MD5 code, which is part of
compats.c.  Lastly, move ifdefs to ifs, remove defined (same), and also
remove HAVE_CONFIG_H.
2017-10-18 21:36:59 +00:00
kristapsdz 11f90226c4 Add in experimental function for converting into UTC date strings. 2016-12-15 22:20:37 +00:00
kristapsdz 06f7f4941d Provide a version of the epoch translator that allows working directly with
the broken-down values.
Fix the manpage for the existing functions, then add the new ones.
2016-11-01 00:24:11 +00:00
kristapsdz 01597fa15a Add kutil_datetime2epoch (for good measure). 2016-10-10 20:50:57 +00:00
kristapsdz ee6463efc6 Add archive of versions, continue fleshing out current version. 2016-10-10 08:26:33 +00:00
kristapsdz 511b3f4bd5 Rename kutil_http_datetime to kutil_epoch2str and also add kutil_date2epoch,
which is internally used by kvalid_date.
2016-10-10 07:47:26 +00:00