diff --git a/0001-fix-build-for-compilers-without-anonymous-struct-ini.patch b/0001-fix-build-for-compilers-without-anonymous-struct-ini.patch new file mode 100644 index 0000000..9e32d02 --- /dev/null +++ b/0001-fix-build-for-compilers-without-anonymous-struct-ini.patch @@ -0,0 +1,242 @@ +From e1d38700985ebe944554821e4758b03bf011b18f Mon Sep 17 00:00:00 2001 +From: Ruediger Meier +Date: Fri, 12 Jun 2015 12:36:49 +0200 +Subject: [PATCH] fix build for compilers without anonymous struct + initialisation + +Signed-off-by: Ruediger Meier +--- + lib/date-core.h | 6 ++++++ + lib/dt-core-strpf.c | 8 ++++++++ + lib/dt-core-tz-glue.c | 16 ++++++++++++++++ + lib/dt-core.c | 4 ++-- + src/dround.c | 15 ++++++++++++++- + src/dseq.c | 27 ++++++++++----------------- + test/dtcore-add.c | 6 +++--- + 7 files changed, 59 insertions(+), 23 deletions(-) + +diff --git a/lib/date-core.h b/lib/date-core.h +index 5b55154..044d69e 100644 +--- a/lib/date-core.h ++++ b/lib/date-core.h +@@ -566,7 +566,13 @@ dt_make_ymcw(unsigned int y, unsigned int m, unsigned int c, unsigned int w) + static inline struct dt_ddur_s + dt_make_ddur(dt_durtyp_t typ, dt_dur_t d) + { ++#if defined HAVE_ANON_STRUCTS_INIT + return (struct dt_ddur_s){typ, .dv = d}; ++#else ++ struct dt_ddur_s res = {typ}; ++ res.dv = d; ++ return res; ++#endif + } + + static inline dt_bizda_param_t +diff --git a/lib/dt-core-strpf.c b/lib/dt-core-strpf.c +index 9aec1fd..c19ae3a 100644 +--- a/lib/dt-core-strpf.c ++++ b/lib/dt-core-strpf.c +@@ -133,7 +133,15 @@ __fixup_zdiff(struct dt_dt_s dt, int32_t zdiff) + { + /* apply time zone difference */ + /* reuse dt for result */ ++#if defined HAVE_ANON_STRUCTS_INIT + dt = dt_dtadd(dt, (struct dt_dtdur_s){DT_DURS, .dv = -zdiff}); ++#else ++ { ++ struct dt_dtdur_s tmp = {DT_DURS}; ++ tmp.dv = -zdiff; ++ dt = dt_dtadd(dt, tmp); ++ } ++#endif + dt.znfxd = 1; + return dt; + } +diff --git a/lib/dt-core-tz-glue.c b/lib/dt-core-tz-glue.c +index ee7d5cd..cb1314d 100644 +--- a/lib/dt-core-tz-glue.c ++++ b/lib/dt-core-tz-glue.c +@@ -74,7 +74,15 @@ dtz_forgetz(struct dt_dt_s d, zif_t zone) + d_unix = zif_utc_time(zone, d_locl); + if (LIKELY((zdiff = d_unix - d_locl))) { + /* let dt_dtadd() do the magic */ ++#if defined HAVE_ANON_STRUCTS_INIT + d = dt_dtadd(d, (struct dt_dtdur_s){DT_DURS, .dv = zdiff}); ++#else ++ { ++ struct dt_dtdur_s tmp = {DT_DURS}; ++ tmp.dv = zdiff; ++ d = dt_dtadd(d, tmp); ++ } ++#endif + d.znfxd = 1; + if (zdiff > 0) { + d.neg = 1; +@@ -108,7 +116,15 @@ dtz_enrichz(struct dt_dt_s d, zif_t zone) + d_locl = zif_local_time(zone, d_unix); + if (LIKELY((zdiff = d_locl - d_unix))) { + /* let dt_dtadd() do the magic */ ++#if defined HAVE_ANON_STRUCTS_INIT + d = dt_dtadd(d, (struct dt_dtdur_s){DT_DURS, .dv = zdiff}); ++#else ++ { ++ struct dt_dtdur_s tmp = {DT_DURS}; ++ tmp.dv = zdiff; ++ d = dt_dtadd(d, tmp); ++ } ++#endif + if (zdiff > 0) { + d.zdiff = (uint16_t)(zdiff / ZDIFF_RES); + } else if (zdiff < 0) { +diff --git a/lib/dt-core.c b/lib/dt-core.c +index 76a78fe..99a0169 100644 +--- a/lib/dt-core.c ++++ b/lib/dt-core.c +@@ -906,7 +906,7 @@ DEFUN struct dt_dtdur_s + dt_strpdtdur(const char *str, char **ep) + { + /* at the moment we allow only one format */ +- struct dt_dtdur_s res = {.durtyp = (dt_dtdurtyp_t)DT_DURUNK}; ++ struct dt_dtdur_s res = {(dt_dtdurtyp_t)DT_DURUNK}; + const char *sp; + long int tmp; + +@@ -1503,7 +1503,7 @@ dt_dtadd(struct dt_dt_s d, struct dt_dtdur_s dur) + DEFUN struct dt_dtdur_s + dt_dtdiff(dt_dtdurtyp_t tgttyp, struct dt_dt_s d1, struct dt_dt_s d2) + { +- struct dt_dtdur_s res = {.durtyp = (dt_dtdurtyp_t)DT_DURUNK}; ++ struct dt_dtdur_s res = {(dt_dtdurtyp_t)DT_DURUNK}; + int dt = 0; + + if (!dt_sandwich_only_d_p(d1) && !dt_sandwich_only_d_p(d2)) { +diff --git a/src/dround.c b/src/dround.c +index 623aaf3..1142164 100644 +--- a/src/dround.c ++++ b/src/dround.c +@@ -500,7 +500,7 @@ dt_io_strpdtrnd(struct __strpdtdur_st_s *st, const char *str) + char *sp = NULL; + struct strpd_s d = strpd_initialiser(); + struct dt_spec_s s = spec_initialiser(); +- struct dt_dtdur_s payload = {.durtyp = (dt_dtdurtyp_t)DT_DURUNK}; ++ struct dt_dtdur_s payload = {(dt_dtdurtyp_t)DT_DURUNK}; + bool negp = false; + bool coclp = true; + +@@ -525,12 +525,19 @@ dt_io_strpdtrnd(struct __strpdtdur_st_s *st, const char *str) + s.spfl = DT_SPFL_S_WDAY; + s.abbr = DT_SPMOD_NORM; + if (__strpd_card(&d, str, s, &sp) >= 0) { ++#if defined HAVE_ANON_STRUCTS_INIT + payload.d = (struct dt_ddur_s){ + DT_DURYMCW, + .neg = negp, + .cocl = coclp, + .ymcw.w = d.w, + }; ++#else ++ payload.d.durtyp = DT_DURYMCW; ++ payload.d.neg = negp; ++ payload.d.cocl = coclp; ++ payload.d.ymcw.w = d.w; ++#endif + goto out; + } + +@@ -538,11 +545,17 @@ dt_io_strpdtrnd(struct __strpdtdur_st_s *st, const char *str) + s.spfl = DT_SPFL_S_MON; + s.abbr = DT_SPMOD_NORM; + if (__strpd_card(&d, str, s, &sp) >= 0) { ++#if defined HAVE_ANON_STRUCTS_INIT + payload.d = (struct dt_ddur_s){ + DT_DURYMD, + .neg = negp, + .ymd.m = d.m, + }; ++#else ++ payload.d.durtyp = DT_DURYMD; ++ payload.d.neg = negp; ++ payload.d.ymd.m = d.m; ++#endif + goto out; + } + +diff --git a/src/dseq.c b/src/dseq.c +index b4bf405..9dc58f1 100644 +--- a/src/dseq.c ++++ b/src/dseq.c +@@ -426,29 +426,22 @@ __fixup_fst(struct dseq_clo_s *clo) + static struct dt_dtdur_s + tseq_guess_ite(struct dt_t_s beg, struct dt_t_s end) + { ++ struct dt_dtdur_s res = {0}; ++ + if (beg.hms.h != end.hms.h && +- beg.hms.m == 0 && end.hms.m == 0&& ++ beg.hms.m == 0 && end.hms.m == 0 && + beg.hms.s == 0 && end.hms.s == 0) { +- if (beg.u < end.u) { +- return (struct dt_dtdur_s){DT_DURH, .dv = 1}; +- } else { +- return (struct dt_dtdur_s){DT_DURH, .dv = -1}; +- } ++ res.durtyp = DT_DURH; ++ res.dv = (beg.u < end.u) ? 1 : -1; + } else if (beg.hms.m != end.hms.m && + beg.hms.s == 0 && end.hms.s == 0) { +- if (beg.u < end.u) { +- return (struct dt_dtdur_s){DT_DURM, .dv = 1}; +- } else { +- return (struct dt_dtdur_s){DT_DURM, .dv = -1}; +- } ++ res.durtyp = DT_DURM; ++ res.dv = (beg.u < end.u) ? 1 : -1; + } else { +- if (beg.u < end.u) { +- return (struct dt_dtdur_s){DT_DURS, .dv = 1}; +- } else { +- return (struct dt_dtdur_s){DT_DURS, .dv = -1}; +- } ++ res.durtyp = DT_DURS; ++ res.dv = (beg.u < end.u) ? 1 : -1; + } +- /* no reach */ ++ return res; + } + + +diff --git a/test/dtcore-add.c b/test/dtcore-add.c +index bfdea28..ff0c49e 100644 +--- a/test/dtcore-add.c ++++ b/test/dtcore-add.c +@@ -67,7 +67,7 @@ add_t_only(void) + { + static const char str[] = "12:34:56"; + struct dt_dt_s d; +- struct dt_dtdur_s dur = {.durtyp = (dt_dtdurtyp_t)DT_DURUNK}; ++ struct dt_dtdur_s dur = {(dt_dtdurtyp_t)DT_DURUNK}; + int res = 0; + + /* 2012-03-28 (using no format) */ +@@ -166,7 +166,7 @@ dt_add_t(void) + { + static const char str[] = "2012-03-28T23:12:01"; + struct dt_dt_s d; +- struct dt_dtdur_s dur = {.durtyp = (dt_dtdurtyp_t)DT_DURUNK}; ++ struct dt_dtdur_s dur = {(dt_dtdurtyp_t)DT_DURUNK}; + int res = 0; + + fprintf(stderr, "testing %s +1h ...\n", str); +@@ -221,7 +221,7 @@ dt_add_dt(void) + { + static const char str[] = "2012-03-28T23:55:55"; + struct dt_dt_s d; +- struct dt_dtdur_s dur = {.durtyp = (dt_dtdurtyp_t)DT_DURUNK}; ++ struct dt_dtdur_s dur = {(dt_dtdurtyp_t)DT_DURUNK}; + int res = 0; + + fprintf(stderr, "testing %s +1d1h ...\n", str); +-- +1.8.4.5 + diff --git a/0002-fix-dateadd-unix-timestamp-bug.patch b/0002-fix-dateadd-unix-timestamp-bug.patch new file mode 100644 index 0000000..8f49f75 --- /dev/null +++ b/0002-fix-dateadd-unix-timestamp-bug.patch @@ -0,0 +1,107 @@ +From 6bf090ff595eb6e8da2a3be4812ddad3411d70ee Mon Sep 17 00:00:00 2001 +From: Ruediger Meier +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 +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 +Date: Mon Jun 15 07:34:02 2015 +0000 + + test, add regression tests for dateadd(1) +2m bug + +Signed-off-by: Ruediger Meier +--- + 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 + diff --git a/dateutils-0.3.2.tar.xz b/dateutils-0.3.2.tar.xz deleted file mode 100644 index eb27deb..0000000 --- a/dateutils-0.3.2.tar.xz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:551620b01c08d5feffb68fde6bb669fe09275dd316a79aeca0efcbe3ec774a3e -size 586156 diff --git a/dateutils-0.3.3.tar.xz b/dateutils-0.3.3.tar.xz new file mode 100644 index 0000000..f879f63 --- /dev/null +++ b/dateutils-0.3.3.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3eb0b1dbf4519c86bc890a12c78cc85eae2cc10c20ff894a90ed55140efeee7a +size 593700 diff --git a/dateutils.changes b/dateutils.changes index 498e50a..494d216 100644 --- a/dateutils.changes +++ b/dateutils.changes @@ -1,3 +1,31 @@ +------------------------------------------------------------------- +Sun Aug 2 15:36:05 UTC 2015 - mpluskal@suse.com + +- Correct previous changelog entries (incorrect patch names) + +------------------------------------------------------------------- +Mon Jun 15 09:02:13 UTC 2015 - sweet_f_a@gmx.de + +- add 0002-fix-dateadd-unix-timestamp-bug.patch + +------------------------------------------------------------------- +Wed Jun 10 14:04:28 UTC 2015 - sweet_f_a@gmx.de + +- 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 0001-fix-build-for-compilers-without-anonymous-struct-ini.patch + to support broken compilers (SLE 11, RHEL 6, etc.) + ------------------------------------------------------------------- Thu Mar 5 16:25:37 UTC 2015 - sweet_f_a@gmx.de diff --git a/dateutils.spec b/dateutils.spec index 90f6113..9f04236 100644 --- a/dateutils.spec +++ b/dateutils.spec @@ -1,7 +1,7 @@ # # spec file for package dateutils # -# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,7 +16,7 @@ # -%define xversion 0.3.2 +%define xversion 0.3.3 %define have_octave 0 @@ -39,13 +39,15 @@ %endif Name: dateutils -Version: 0.3.2 +Version: 0.3.3 Release: 0 Summary: Nifty command line date and time utilities License: BSD-3-Clause Group: Productivity/Text/Utilities Url: https://github.com/hroptatyr/dateutils/ Source: https://bitbucket.org/hroptatyr/dateutils/downloads/%{name}-%{version}.tar.xz +Patch1: 0001-fix-build-for-compilers-without-anonymous-struct-ini.patch +Patch2: 0002-fix-dateadd-unix-timestamp-bug.patch BuildRequires: pkgconfig BuildRequires: xz %if 0%{?suse_version} @@ -79,6 +81,8 @@ Dateutils can be used from within matlab or ocatave. %prep %setup -q -n %{name}-%{xversion} +%patch1 -p1 +%patch2 -p1 %build %configure \ @@ -124,6 +128,15 @@ rm -rf %{buildroot} %{_bindir}/dsort %{_bindir}/dtest %{_bindir}/dzone +%{_bindir}/dateadd +%{_bindir}/dateconv +%{_bindir}/datediff +%{_bindir}/dategrep +%{_bindir}/dateround +%{_bindir}/dateseq +%{_bindir}/datesort +%{_bindir}/datetest +%{_bindir}/datezone %{_bindir}/strptime %dir %{_datadir}/dateutils/ %{_datadir}/dateutils/*.tzmcc @@ -138,6 +151,15 @@ rm -rf %{buildroot} %doc %{_mandir}/man1/dsort.1* %doc %{_mandir}/man1/dtest.1* %doc %{_mandir}/man1/dzone.1* +%doc %{_mandir}/man1/dateadd.1* +%doc %{_mandir}/man1/dateconv.1* +%doc %{_mandir}/man1/datediff.1* +%doc %{_mandir}/man1/dategrep.1* +%doc %{_mandir}/man1/dateround.1* +%doc %{_mandir}/man1/dateseq.1* +%doc %{_mandir}/man1/datesort.1* +%doc %{_mandir}/man1/datetest.1* +%doc %{_mandir}/man1/datezone.1* %doc %{_mandir}/man1/strptime.1* %if %have_octave