dateutils/0002-fix-dateadd-unix-timestamp-bug.patch
Ruediger Meier ebe51fdb19 Accepting request 312075 from home:rudi_m
- add fix-dateadd-unix-timestamp-bug.patch

- bump version 0.3.3, this is a feature release.
  * Features:
    - to clarify purpose and avoid name clashes prefix binaries
      with "date". This results in: dateadd, dateconv, ... etc.
    - provide compatibilty through configure switch --with-old-names
    - provide single digit years through %_y
    - allow rounding of ISO-week dates (ywd) to week numbers
  * Bugfixes:
    - dashes behind a date do not count as tz indicator
    - UTC/TAI/GPS special coordinated zones work on systems without
      leap second support
  * See info page examples and/or README 
- add fix-build-for-compilers-without-anonymous-struct-ini.patch
  to support broken compilers (SLE 11, RHEL 6, etc.)

OBS-URL: https://build.opensuse.org/request/show/312075
OBS-URL: https://build.opensuse.org/package/show/utilities/dateutils?expand=0&rev=36
2015-06-29 11:48:55 +00:00

108 lines
2.8 KiB
Diff

From 6bf090ff595eb6e8da2a3be4812ddad3411d70ee Mon Sep 17 00:00:00 2001
From: Ruediger Meier <ruediger.meier@ga-group.nl>
Date: Mon, 15 Jun 2015 10:56:42 +0200
Subject: [PATCH] fix dateadd unix timestamp bug
Squashed commit of the following:
commit c9f4ec3ad2c3272387b25718b9f8d421537d2d6a
Author: Sebastian Freundt <freundt@ga-group.nl>
Date: Mon Jun 15 08:07:12 2015 +0000
fix, PEBKAC, actually add hours and minutes if requested to sexy date/times
commit 8bc0fd838e782b8c24a2024d33da39c544aaa345
Author: Sebastian Freundt <freundt@ga-group.nl>
Date: Mon Jun 15 07:34:02 2015 +0000
test, add regression tests for dateadd(1) +2m bug
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
lib/dt-core.c | 13 ++++++++-----
test/Makefile.am | 2 ++
test/dtadd.049.clit | 6 ++++++
test/dtadd.050.clit | 5 +++++
4 files changed, 21 insertions(+), 5 deletions(-)
create mode 100644 test/dtadd.049.clit
create mode 100644 test/dtadd.050.clit
diff --git a/lib/dt-core.c b/lib/dt-core.c
index 99a0169..17afb90 100644
--- a/lib/dt-core.c
+++ b/lib/dt-core.c
@@ -249,26 +249,29 @@ __sexy_add(dt_sexy_t sx, struct dt_dtdur_s dur)
/* sexy add
* only works for continuous types (DAISY, etc.)
* we need to take leap seconds into account here */
- signed int delta = 0;
+ dt_ssexy_t dv = dur.dv;
switch (dur.durtyp) {
case DT_DURH:
+ dv *= MINS_PER_HOUR;
case DT_DURM:
+ dv *= SECS_PER_MIN;
case DT_DURS:
+ break;
case DT_DURNANO:
- delta = dur.dv;
+ dv /= NANOS_PER_SEC;
break;
case DT_DURD:
case DT_DURBD:
- delta = dur.d.dv * SECS_PER_DAY;
+ dv = dur.d.dv * SECS_PER_DAY;
/*@fallthrough@*/
case DT_DURUNK:
- delta += dur.t.sdur;
+ dv += dur.t.sdur;
default:
break;
}
/* just go through with it */
- return sx + delta;
+ return sx + dv;
}
#if defined WITH_LEAP_SECONDS && defined SKIP_LEAP_ARITH
diff --git a/test/Makefile.am b/test/Makefile.am
index 83acebb..11ac574 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -686,6 +686,8 @@ dt_tests += dtadd.045.clit
dt_tests += dtadd.046.clit
dt_tests += dtadd.047.clit
dt_tests += dtadd.048.clit
+dt_tests += dtadd.049.clit
+dt_tests += dtadd.050.clit
dt_tests += dtgrep.001.clit
dt_tests += dtgrep.002.clit
diff --git a/test/dtadd.049.clit b/test/dtadd.049.clit
new file mode 100644
index 0000000..d8300d0
--- /dev/null
+++ b/test/dtadd.049.clit
@@ -0,0 +1,6 @@
+#!/usr/bin/clitoris ## -*- shell-script -*-
+
+$ dadd -z "Europe/Berlin" "2015-06-13T00:18:20" "+2m" -f "%Y%m%d %T Europe/Berlin"
+20150613 02:20:20 Europe/Berlin
+$
+
diff --git a/test/dtadd.050.clit b/test/dtadd.050.clit
new file mode 100644
index 0000000..36ae2cd
--- /dev/null
+++ b/test/dtadd.050.clit
@@ -0,0 +1,5 @@
+#!/usr/bin/clitoris ## -*- shell-script -*-
+
+$ dadd -z "Europe/Berlin" "@1434147500" "+2m" -f "%Y%m%d %T Europe/Berlin"
+20150613 00:20:20 Europe/Berlin
+$
--
1.8.4.5