aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/ChangeLog5
-rw-r--r--util/miscutil.c18
2 files changed, 18 insertions, 5 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
index e5928a32a..767d0bea7 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,8 @@
+2010-10-27 Werner Koch <[email protected]>
+
+ * miscutil.c (INVALID_TIME_CHECK): New.
+ (strtimestamp, isotimestamp, asctimestamp): Use it.
+
2010-09-28 Steven M. Schweda <[email protected]> (wk)
Changes to help the VMS port. See
diff --git a/util/miscutil.c b/util/miscutil.c
index f74d3e38b..16c2b2b4c 100644
--- a/util/miscutil.c
+++ b/util/miscutil.c
@@ -31,6 +31,13 @@
#include "util.h"
#include "i18n.h"
+#ifdef HAVE_UNSIGNED_TIME_T
+# define INVALID_TIME_CHECK(a) ((a) == (time_t)(-1))
+#else
+ /* Error or 32 bit time_t and value after 2038-01-19. */
+# define INVALID_TIME_CHECK(a) ((a) < 0)
+#endif
+
/****************
* I know that the OpenPGP protocol has a Y2106 problem ;-)
*/
@@ -117,8 +124,8 @@ strtimestamp( u32 stamp )
static char buffer[11+5];
struct tm *tp;
time_t atime = stamp;
-
- if (atime < 0) {
+
+ if (INVALID_TIME_CHECK (atime)) {
strcpy (buffer, "????" "-??" "-??");
}
else {
@@ -140,7 +147,7 @@ isotimestamp (u32 stamp)
struct tm *tp;
time_t atime = stamp;
- if (atime < 0) {
+ if (INVALID_TIME_CHECK (atime)) {
strcpy (buffer, "????" "-??" "-??" " " "??" ":" "??" ":" "??");
}
else {
@@ -216,10 +223,11 @@ asctimestamp( u32 stamp )
struct tm *tp;
time_t atime = stamp;
- if (atime < 0) {
+ if (INVALID_TIME_CHECK (atime))
+ {
strcpy (buffer, "????" "-??" "-??");
return buffer;
- }
+ }
tp = localtime( &atime );
#ifdef HAVE_STRFTIME