Git Product home page Git Product logo

dateutils's Introduction

Dateutils

Build Status build status Coverity Scan Build Status

Dateutils are a bunch of tools that revolve around fiddling with dates and times on the command line with a strong focus on use cases that arise when dealing with large amounts of financial data.

Dateutils are hosted primarily on github:

Below is a short list of examples that demonstrate what dateutils can do, for full specs refer to the info and man pages. For installation instructions refer to the INSTALL file.

Dateutils commands are prefixed with a date but otherwise resemble known unix commands for reasons of intuition. The only exception being strptime which is analogous to the libc function of the same name.

  • strptime Command line version of the C function
  • dateadd Add durations to dates or times
  • dateconv Convert dates or times between calendars
  • datediff Compute durations between dates or times
  • dategrep Grep dates or times in input streams
  • dateround Round dates or times to "fuller" values
  • dateseq Generate sequences of dates or times
  • datesort Sort chronologically.
  • datetest Compare dates or times
  • datezone Convert date/times to timezones in bulk

Examples

I love everything explained by example to get a first impression. So here it comes.

dateseq

A tool mimicking seq(1) but whose inputs are from the domain of dates rather than integers. Typically scripts use something like

$ for i in $(seq 0 9); do
    date -d "2010-01-01 +${i} days" "+%F"
  done

which now can be shortened to

$ dateseq 2010-01-01 2010-01-10

with the additional benefit that the end date can be given directly instead of being computed from the start date and an interval in days. Also, it provides date specific features that would be a PITA to implement using the above seq(1)/date(1) approach, like skipping certain weekdays:

$ dateseq 2010-01-01 2010-01-10 --skip sat,sun
=>  
  2010-01-01
  2010-01-04
  2010-01-05
  2010-01-06
  2010-01-07
  2010-01-08

dateseq also works on times:

$ dateseq 12:00:00 5m 12:17:00
=>
  12:00:00
  12:05:00
  12:10:00
  12:15:00

and also date-times:

$ dateseq --compute-from-last 2012-01-02T12:00:00 5m 2012-01-02T12:17:00
=>
  2012-01-02T12:02:00
  2012-01-02T12:07:00
  2012-01-02T12:12:00
  2012-01-02T12:17:00

dateconv

A tool to convert dates between different calendric systems and/or time zones. While other such tools usually focus on converting Gregorian dates to, say, the Chinese calendar, dconv aims at supporting calendric systems which are essential in financial contexts.

To convert a (Gregorian) date into the so called ymcw representation:

$ dateconv 2012-03-04 -f "%Y-%m-%c-%w"
=>
  2012-03-01-00

and vice versa:

$ dateconv 2012-03-01-Sun -i "%Y-%m-%c-%a" -f '%F'
=>
  2012-03-04

where the ymcw representation means, the %c-th %w of the month in a given year. This is useful if dates are specified like, the third Thursday in May for instance.

dateconv can also be used to convert occurrences of dates, times or date-times in an input stream on the fly

$ dateconv -S -i '%b/%d %Y at %I:%M %P' <<EOF
Remember we meet on Mar/03 2012 at 02:30 pm
EOF
=>
  Remember we meet on 2012-03-03T14:30:00

and most prominently to convert between time zones:

$ dateconv --from-zone "America/Chicago" --zone "Asia/Tokyo" 2012-01-04T09:33:00
=>
  2012-01-05T00:33:00

$ dateconv --zone "America/Chicago" now -f "%d %b %Y %T"
=>
  05 Apr 2012 11:11:57

datetest

A tool to perform date comparison in the shell, it's modelled after test(1) but with proper command line options.

$ if datetest today --gt 2010-01-01; then
    echo "yes"
  fi
=>
  yes

dateadd

A tool to perform date arithmetic (date maths) in the shell. Given a date and a list of durations this will compute new dates. Given a duration and a list of dates this will compute new dates.

$ dateadd 2010-02-02 +4d
=>
  2010-02-06

$ dateadd 2010-02-02 +1w
=>
  2010-02-09

$ dateadd -1d <<EOF
2001-01-05
2001-01-01
EOF
=>
  2001-01-04
  2000-12-31

Adding durations to times:

$ dateadd 12:05:00 +10m
=>
  12:15:00

and even date-times:

$ dateadd 2012-03-12T12:05:00 -1d4h
=>
  2012-03-11T08:05:00

If supported by the system's zoneinfo database leap-second adjusted calculations are possible. Use the unit rs to denote "real" seconds:

$ dateadd '2012-06-30 23:59:30' +30rs
=>
  2012-06-30T23:59:60

as opposed to:

$ dateadd '2012-06-30 23:59:30' +30s
=>
  2012-07-01T00:00:00

datediff

A tool to calculate the difference between two (or more) dates. This is somewhat the converse of dadd. Outputs will be durations that, when added to the first date, give the second date.

Get the number of days between two dates:

$ datediff 2001-02-08 2001-03-02
=>
  22

The duration format can be controlled through the -f switch:

$ datediff 2001-02-08 2001-03-09 -f "%m month and %d day"
=>
  1 month and 1 day

datediff also accepts time stamps as input:

$ datediff 2012-03-01T12:17:00 2012-03-02T14:00:00
=>
  92580s

The -f switch does the right thing:

$ datediff 2012-03-01T12:17:00 2012-03-02T14:00:00 -f '%dd %Ss'
=>
  1d 6180s

compare to:

$ datediff 2012-03-01T12:17:00 2012-03-02T14:00:00 -f '%dd %Hh %Ss'
=>
  1d 1h 2580s

If supported by the system's zoneinfo database leap-second adjusted calculations can be made. Use the format specifier %rS to get the elapsed time in "real" seconds:

datediff '2012-06-30 23:59:30' '2012-07-01 00:00:30' -f '%rS'
=>
  61

dategrep

A tool to extract lines from an input stream that match certain criteria, showing either the line or the match:

$ dategrep '<2012-03-01' <<EOF
Feb	2012-02-28
Feb	2012-02-29	leap day
Mar	2012-03-01
Mar	2012-03-02
EOF
=>
  Feb	2012-02-28
  Feb	2012-02-29	leap day

dateround

A tool to "round" dates or time stamps to a recurring point in time, like the next/previous January or the next/previous Thursday.

Round (backwards) to the first of the current month:

$ dateround '2011-08-22' -1
=>
  2011-08-01

Find the next Monday from the current date (today is 2016-01-08):

$ dateround today Mon
=>
  2015-01-11

Go back to last September, then round to the end of the month:

$ dateround today -- -Sep +31d
=>
  2015-09-30

Round a stream of dates strictly to the next month's first:

$ dateround -S -n 1 <<EOF
pay cable	2012-02-28
pay gas	2012-02-29
pay rent	2012-03-01
redeem loan	2012-03-02
EOF
=>
  pay cable	2012-03-01
  pay gas	2012-03-01
  pay rent	2012-04-01
  redeem loan	2012-04-01

Round a timeseries to the next minute (i.e. the seconds part is 00) and then to the next half-past time (and convert to ISO):

$ dateround -S 0s30m -i '%d/%m/%Y %T' -f '%F %T' <<EOF
06/03/2012 14:27:12	eventA
06/03/2012 14:29:59	eventA
06/03/2012 14:30:00	eventB
06/03/2012 14:30:01	eventB
EOF
=>
  2012-03-06 14:30:00	eventA
  2012-03-06 14:30:00	eventA
  2012-03-06 14:30:00	eventB
  2012-03-06 15:30:00	eventB

Alternatively, if you divide the day into half-hours you can round to one of those using the co-class notation:

$ dateround -S /30m -i '%d/%m/%Y %T' -f '%F %T' <<EOF
06/03/2012 14:27:12	eventA
06/03/2012 14:29:59	eventA
06/03/2012 14:30:00	eventB
06/03/2012 14:30:01	eventB
EOF
=>
  2012-03-06 14:30:00	eventA
  2012-03-06 14:30:00	eventA
  2012-03-06 14:30:00	eventB
  2012-03-06 15:00:00	eventB

This is largely identical to the previous example except, that a full hour (being an even multiple of half-hours) is a possible rounding target.

datesort

A tool to bring the lines of a file into chronological order.

At the moment the datesort tool depends on sort(1) with support for fields, in particular -t to select a separator and -k to sort by a particular field.

$ datesort <<EOF
2009-06-03 caev="DVCA" secu="VOD" exch="XLON" xdte="2009-06-03" nett/GBX="5.2"
2011-11-16 caev="DVCA" secu="VOD" exch="XLON" xdte="2011-11-16" nett/GBX="3.05"
2013-11-20 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-11-20" nett/GBX="3.53"
2012-06-06 caev="DVCA" secu="VOD" exch="XLON" xdte="2012-06-06" nett/GBX="6.47"
2013-06-12 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-06-12" nett/GBX="6.92"
2010-11-17 caev="DVCA" secu="VOD" exch="XLON" xdte="2010-11-17" nett/GBX="2.85"
EOF
=>
  2009-06-03 caev="DVCA" secu="VOD" exch="XLON" xdte="2009-06-03" nett/GBX="5.2"
  2010-11-17 caev="DVCA" secu="VOD" exch="XLON" xdte="2010-11-17" nett/GBX="2.85"
  2011-11-16 caev="DVCA" secu="VOD" exch="XLON" xdte="2011-11-16" nett/GBX="3.05"
  2012-06-06 caev="DVCA" secu="VOD" exch="XLON" xdte="2012-06-06" nett/GBX="6.47"
  2013-06-12 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-06-12" nett/GBX="6.92"
  2013-11-20 caev="DVCA" secu="VOD" exch="XLON" xdte="2013-11-20" nett/GBX="3.53"

datezone

A tool to quickly inspect date/time values in different timezones. The result will be a matrix that shows every date-time value in every timezone:

$ datezone Europe/Berlin Australia/Sydney now 2014-06-30T05:00:00
=>
  2014-01-30T17:37:13+01:00	Europe/Berlin
  2014-01-31T03:37:13+11:00	Australia/Sydney
  2014-06-30T07:00:00+02:00	Europe/Berlin
  2014-06-30T15:00:00+10:00	Australia/Sydney

The datezone tool can also be used to obtain the next or previous DST transition relative to a given date/time:

$ datezone --next Europe/Berlin Australia/Sydney 2013-02-19
=>
  2013-03-31T02:00:00+01:00 -> 2013-03-31T03:00:00+02:00	Europe/Berlin
  2013-04-07T03:00:00+11:00 -> 2013-04-07T02:00:00+10:00	Australia/Sydney

where the left time stamp denotes the current zone offset and the right side is the zone offset after the transition. The date/time indicates the exact moment when the transition is about to take place.

In essence datezone is a better zdump(8).

strptime

A tool that brings the flexibility of strptime(3) to the command line. While (at least GNU) date(1) has support for output formats, it lacks any kind of support to read arbitrary input from the domain of dates, in particular when the input format is specifically known beforehand and only matching dates/times shall be considered.

With the strptime tool reading weird dates like Mon, May-01/2000 becomes a matter of

strptime -i "%a, %b-%d/%Y" "Mon, May-01/2000"
=>
  2000-05-01

just as you would have done in C.

Note that strptime actually uses the system libc's strptime routine, and for output the system's strftime routine. Input and output modifiers will therefore vary between systems.

For a portable parser/printer combination use dateconv as described above. Its input and output format specifiers are independent of the C runtime.

Similar projects

In no particular order and without any claim to completeness:

Use the one that best fits your purpose. And in case you happen to like mine, vote: dateutils' openhub page

dateutils's People

Contributors

aborruso avatar bernhardu avatar bmwiedemann avatar hroptatyr avatar jwilk avatar kianmeng avatar matthewfischer avatar rudimeier avatar shenlanting avatar timgates42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dateutils's Issues

dadd stumbles on ymcw dates

dconv 2012-04-05-06 -f ymd
  => 2012-04-28

but

dadd 2012-04-05-06 1
  => 2012-05-01-00

should be: 2012-04-05-00

NetBSD: 7 test failures

I've tried dateutils-0.2.5 on NetBSD-6.99.24/amd64 and get 7 test failures.

dateutils 0.2.5: test/test-suite.log

7 of 518 tests failed.

.. contents:: :depth: 2

FAIL: dtconv.24.dt (exit: 1)

.../dateutils-0.2.5/src/dconv '2012-03-01 00:00:00' -z TAI<<EOF
EOF

--- dtconv.24.dt.tmpd/exp_stdout 2013-10-21 16:51:30.000000000 +0200
+++ dtconv.24.dt.tmpd/tool_stdout 2013-10-21 16:51:30.000000000 +0200
@@ -1 +1 @@
-2012-03-01T00:00:34
+2012-03-01T00:00:00

FAIL: dtconv.26.dt (exit: 1)

.../dateutils-0.2.5/src/dconv '2012-03-01 00:00:00' -z GPS<<EOF
EOF

--- dtconv.26.dt.tmpd/exp_stdout 2013-10-21 16:51:30.000000000 +0200
+++ dtconv.26.dt.tmpd/tool_stdout 2013-10-21 16:51:30.000000000 +0200
@@ -1 +1 @@
-2012-03-01T00:00:15
+2012-03-01T00:00:00

FAIL: dtconv.27.dt (exit: 1)

.../dateutils-0.2.5/src/dconv '2012-03-01 00:00:00' --from-zone TAI<<EOF
EOF

--- dtconv.27.dt.tmpd/exp_stdout 2013-10-21 16:51:30.000000000 +0200
+++ dtconv.27.dt.tmpd/tool_stdout 2013-10-21 16:51:30.000000000 +0200
@@ -1 +1 @@
-2012-02-29T23:59:26
+2012-03-01T00:00:00

FAIL: dtconv.29.dt (exit: 1)

.../dateutils-0.2.5/src/dconv '2012-03-01 00:00:00' --from-zone GPS<<EOF
EOF

--- dtconv.29.dt.tmpd/exp_stdout 2013-10-21 16:51:30.000000000 +0200
+++ dtconv.29.dt.tmpd/tool_stdout 2013-10-21 16:51:30.000000000 +0200
@@ -1 +1 @@
-2012-02-29T23:59:45
+2012-03-01T00:00:00

FAIL: dtconv.30.dt (exit: 1)

.../dateutils-0.2.5/src/dconv '1970-01-01 00:00:00' -z TAI<<EOF
EOF

--- dtconv.30.dt.tmpd/exp_stdout 2013-10-21 16:51:30.000000000 +0200
+++ dtconv.30.dt.tmpd/tool_stdout 2013-10-21 16:51:30.000000000 +0200
@@ -1 +1 @@
-1970-01-01T00:00:10
+1970-01-01T00:00:00

FAIL: dtconv.31.dt (exit: 1)

.../dateutils-0.2.5/src/dconv '1972-01-01 00:00:00' -z TAI<<EOF
EOF

--- dtconv.31.dt.tmpd/exp_stdout 2013-10-21 16:51:30.000000000 +0200
+++ dtconv.31.dt.tmpd/tool_stdout 2013-10-21 16:51:30.000000000 +0200
@@ -1 +1 @@
-1972-01-01T00:00:10
+1972-01-01T00:00:00

FAIL: dtconv.32.dt (exit: 1)

.../dateutils-0.2.5/src/dconv '1972-01-01 00:00:01' -z TAI<<EOF
EOF

--- dtconv.32.dt.tmpd/exp_stdout 2013-10-21 16:51:30.000000000 +0200
+++ dtconv.32.dt.tmpd/tool_stdout 2013-10-21 16:51:30.000000000 +0200
@@ -1 +1 @@
-1972-01-01T00:00:11
+1972-01-01T00:00:01

Incompatible with bison 2.3 on OS X

This suite doesn't compile on OS X 10.10.2 / XCode 6.1.1 that ships with a somewhat outdated version of bison:

.../dateutils/src/dexpr-parser.y:39.9-17: syntax error, unexpected string, expecting =

$ yacc -V
bison (GNU Bison) 2.3
Written by Robert Corbett and Richard Stallman.

Either fixing dexpr-parser.y or installing a more recent bison from MacPorts resolves that issue.

But I still get a couple of warnings for your extern inline declarations...

ddiff calculation error?

$ ddiff -f '%yy %mm %dd' 2008-6-29 2009-6-29
0y 11m 31d

when I add one day to the ending date, I should get "1y 0m, 0d", right?
$ ddiff -f '%yy %mm %dd' 2008-6-29 2009-6-30
1y 0m 1d

Also, when you do a lease-like calculation, one year duration would be
from 2008-6-29 to 2009-6-28
$ ddiff -f '%yy %mm %dd' 2008-6-29 2009-6-28
0y 11m 30d

with time specified, no luck either.
$ ddiff -f '%yy %mm %dd %Hh %Mm %Ss' 2008-6-29T00:00:00 2009-6-28T24:00:00
0y 11m 30d 0h 0m 0s
$ ddiff -f '%yy %mm %dd %Hh %Mm %Ss' 2008-6-29T00:00:00 2009-6-29T24:00:00
0y 11m 31d 0h 0m 0s

I'm using version 0.2.5, haven't tried the new release yet.

0.4.1 fails to build on FreeBSD 11.0-RELEASE-p6

Hello,

I'm working on sysutils/dateutils FreeBSD port and encountered following build error:

===>  Building for dateutils-0.4.1
Making all in build-aux
/usr/bin/make  all-am
cc -std=gnu11 -DHAVE_CONFIG_H -I. -I../src  -D_POSIX_C_SOURCE=200809L  -D_XOPEN_SOURCE=700 -D_BSD_SOURCE  -D_ALL_SOURCE -D_DARWIN_C_SOURCE  -D_NETBSD_SOURCE  -DYUCK_TEMPLATE_PATH='"/wrkdirs/usr/ports/sysutils/dateutils/work/dateutils-0.4.1/build-aux"'  -DWITH_SCMVER  -DBOOTSTRAP -DWITH_SCMVER   -O2 -pipe  -fstack-protector -fno-strict-aliasing   -ggdb3  -Wall -Wextra -Wsign-compare -Wno-char-subscripts -Wundef -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Winline -Wbad-function-cast -Wcast-qual -Wcast-align -Wno-switch -Wunused-function -Wunused-variable -Wunused-parameter -Wunused-value -Wunused -fdiagnostics-show-option -Wunknown-pragmas -Wuninitialized -Wreorder -Wdeprecated -Wno-parentheses -Wstrict-aliasing -MT yuck_bootstrap-yuck.o -MD -MP -MF .deps/yuck_bootstrap-yuck.Tpo -c -o yuck_bootstrap-yuck.o `test -f 'yuck.c' || echo './'`yuck.c
mv -f .deps/yuck_bootstrap-yuck.Tpo .deps/yuck_bootstrap-yuck.Po
/bin/sh ../libtool  --tag=CC    --mode=link cc -std=gnu11  -O2 -pipe  -fstack-protector -fno-strict-aliasing   -ggdb3  -Wall -Wextra -Wsign-compare -Wno-char-subscripts -Wundef -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Winline -Wbad-function-cast -Wcast-qual -Wcast-align -Wno-switch -Wunused-function -Wunused-variable -Wunused-parameter -Wunused-value -Wunused -fdiagnostics-show-option -Wunknown-pragmas -Wuninitialized -Wreorder -Wdeprecated -Wno-parentheses -Wstrict-aliasing   -fstack-protector -o yuck-bootstrap yuck_bootstrap-yuck.o  
libtool: link: cc -std=gnu11 -O2 -pipe -fstack-protector -fno-strict-aliasing -ggdb3 -Wall -Wextra -Wsign-compare -Wno-char-subscripts -Wundef -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Winline -Wbad-function-cast -Wcast-qual -Wcast-align -Wno-switch -Wunused-function -Wunused-variable -Wunused-parameter -Wunused-value -Wunused -fdiagnostics-show-option -Wunknown-pragmas -Wuninitialized -Wreorder -Wdeprecated -Wno-parentheses -Wstrict-aliasing -fstack-protector -o yuck-bootstrap yuck_bootstrap-yuck.o 
cc -std=gnu11 -DHAVE_CONFIG_H -I. -I../src  -D_POSIX_C_SOURCE=200809L  -D_XOPEN_SOURCE=700 -D_BSD_SOURCE  -D_ALL_SOURCE -D_DARWIN_C_SOURCE  -D_NETBSD_SOURCE  -DYUCK_TEMPLATE_PATH='"/wrkdirs/usr/ports/sysutils/dateutils/work/dateutils-0.4.1/build-aux"'  -DWITH_SCMVER   -O2 -pipe  -fstack-protector -fno-strict-aliasing   -ggdb3  -Wall -Wextra -Wsign-compare -Wno-char-subscripts -Wundef -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Winline -Wbad-function-cast -Wcast-qual -Wcast-align -Wno-switch -Wunused-function -Wunused-variable -Wunused-parameter -Wunused-value -Wunused -fdiagnostics-show-option -Wunknown-pragmas -Wuninitialized -Wreorder -Wdeprecated -Wno-parentheses -Wstrict-aliasing -MT yuck-yuck.o -MD -MP -MF .deps/yuck-yuck.Tpo -c -o yuck-yuck.o `test -f 'yuck.c' || echo './'`yuck.c
yuck.c:1160:15: error: use of undeclared identifier 'CTL_KERN'
        int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
                     ^
yuck.c:1160:25: error: use of undeclared identifier 'KERN_PROC'
        int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
                               ^
yuck.c:1160:36: error: use of undeclared identifier 'KERN_PROC_PATHNAME'
        int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
                                          ^
yuck.c:1164:15: warning: implicit declaration of function 'sysctl' is invalid in C99 [-Wimplicit-function-declaration]
        if (UNLIKELY(sysctl(mib, countof(mib), buf, &bsz, NULL, 0) < 0)) {
                     ^
yuck.c:1164:27: error: invalid application of 'sizeof' to an incomplete type 'int []'
        if (UNLIKELY(sysctl(mib, countof(mib), buf, &bsz, NULL, 0) < 0)) {
            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
yuck.c:80:28: note: expanded from macro 'countof'
# define countof(x)     (sizeof(x) / sizeof(*x))
                               ^
yuck.c:73:41: note: expanded from macro 'UNLIKELY'
# define UNLIKELY(_x)   __builtin_expect((_x), 0)
                                          ^~
yuck.c:1361:17: warning: implicitly declaring library function 'vfork' with type 'int (void)' [-Wimplicit-function-declaration]
        switch ((m4p = vfork())) {
                       ^
yuck.c:1361:17: note: include the header <unistd.h> or explicitly provide a declaration for 'vfork'
2 warnings and 4 errors generated.
*** Error code 1

Stop.
make[3]: stopped in /wrkdirs/usr/ports/sysutils/dateutils/work/dateutils-0.4.1/build-aux
*** Error code 1

Stop.
make[2]: stopped in /wrkdirs/usr/ports/sysutils/dateutils/work/dateutils-0.4.1/build-aux
*** Error code 1

Stop.
make[1]: stopped in /wrkdirs/usr/ports/sysutils/dateutils/work/dateutils-0.4.1
*** Error code 1

Stop.
make: stopped in /usr/ports/sysutils/dateutils

Full build log is available here.

Following patch fixed build issue, but I'm not sure that root cause was addressed.

--- ./build-aux/yuck.c.orig       2017-01-09 22:46:09.567046000 +0000
+++ ./build-aux/yuck.c    2017-01-09 22:47:34.812054000 +0000
@@ -61,6 +61,8 @@
 #include <fcntl.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
 #include <time.h>
 #if defined WITH_SCMVER
 # include <yuck-scmver.h>

P.S. Also, for some reason, lib files (include/dateutils/*.h, lib/libdut.a, libdata/pkgconfig/libdut.pc) weren't installed during make install phase, though have been built successfully.

dconv -q goes to infloop

This seems to be the regression:

$ dconv -q <<EOF
xyz
some date: 2013-10-02
EOF

whereas the version without -q seems to work just fine:

$ dconv <<EOF
xyz
some date: 2013-10-02
EOF
=>
  dconv: cannot make sense of `xyz' using the given input formats
  2003-10-10

malicious input crashes dconv

From the debian bug tracker: #775186

Package: dateutils
Version: 0.3.1-1.1
Usertags: afl

dateutils.dconv aborts with failed assertion on this input:

$ echo '2015-2015-00-12-12' | dateutils.dconv
dateutils.dconv: ywd.c:474: __make_ywd_c: Assertion `w != DT_MIRACLEDAY' failed.
Aborted

This bug was found using American fuzzy lop:
https://packages.debian.org/experimental/afl

Disclaimer: I don't have spare CPU cycles, so I fuzzed only till the first crash (which took less than a minute). It's likely that extensive fuzzing would uncover more interesting crashers. I'd encourage dateutils maintainers to perform fuzzing with AFL on their own. :-)

-- System Information:
Debian Release: 8.0
APT prefers unstable
APT policy: (990, 'unstable'), (500, 'experimental')
Architecture: i386 (x86_64)
Foreign Architectures: amd64

Kernel: Linux 3.2.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=pl_PL.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages dateutils depends on:
ii libc6 2.19-13

Jakub Wilk

please include a license file

The license in the source code is BSD-style. It would be nice for packaging of the final binaries if there were also a separate LICENSE documentation file. Thanks!

segfault on missing input format

Example:

$ echo 1900-01-01 | strptime -i '%F'
1900-01-01

$ echo 1900-01-01 | strptime -i 'foo'
strptime: cannot make sense of `1900-01-01' using the given input formats

$ echo 1900-01-01 | strptime -i
Segmentation fault (core dumped)

Not sure if this one is intended...

$ echo 1900-01-01 | strptime -i ''
1900-01-00

Signed release tarballs

Since the commits are already verified, it would be a small step to also sign the release tarballs for distribution packaging.

zonename UTC not recognized on OS X

One of the tests fails:

dateutils 0.3.2.git28.bc5645b: test/test-suite.log

TOTAL: 743

PASS: 742

SKIP: 0

XFAIL: 0

FAIL: 1

XPASS: 0

ERROR: 0

.. contents:: :depth: 2

FAIL: dzone.003

$ dzone 2012-03-04T12:04:11 UTC
dzone: Cannot use `UTC', it does not appear to be a zonename
nor a date/time corresponding to the given input formats
--- expected output 552db850 2015-04-09 13:59:30.000000000 +0200
+++ actual output 552db850 2015-04-09 13:59:30.000000000 +0200
@@ -1 +1 @@
-2012-03-04T12:04:11+00:00 UTC
+2012-03-04T12:04:11+00:00
$? 1
FAIL dzone.003.clit (exit status: 1)

System info:

  • Darwin Kernel Version 14.1.0: Mon Dec 22 23:10:38 PST 2014; root:xnu-2782.10.72~2/RELEASE_X86_64 x86_64
  • $ gcc -v
    Using built-in specs.
    COLLECT_GCC=gcc
    COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/lto-wrapper
    Target: x86_64-apple-darwin14.0.0
    Configured with: ../gcc-4.9-20141029/configure --enable-languages=c++,fortran
    Thread model: posix
    gcc version 4.9.2 20141029 (prerelease) (GCC)
  • $ ls -l /usr/share/zoneinfo/UTC
    -rw-r--r-- 6 root wheel 56 Sep 10 2014 /usr/share/zoneinfo/UTC

minor warning in dgrep man page

Basically, this:

 $ man --warnings ./dgrep.man > /dev/null
 <standard input>:12: warning: macro `>',' not defined

This is ... not what I'd call high priority, but there it is. :)

dconv inconsistency

Inconsistency:

$ rudi@zappa:~> dconv -i "%Y%M%d/%b/%y" -f "%F %T" 20101230
2010-00-00 00:12:00

vs.

$ dconv -i "%d/%b/%y" -f "%F %T" 20101230
dconv: cannot make sense of `20101230' using the given input formats

ddiff day only duration on date/times broken

Also, the output format "%d" doesn't work when used by itself (but does work in
combination with other format specifiers, strangely):

andrewg@xen:~$ dateutils.ddiff -i "%Y%m%d%H%M%S" -f "%d %S" 20150407075744 now
62 36520
andrewg@xen:~$ dateutils.ddiff -i "%Y%m%d%H%M%S" -f "%d" 20150407075744 now
0
andrewg@xen:~$ dateutils.ddiff -i "%Y%m%d%H%M%S" -f "%S" 20150407075744 now
5393331

-- System Information:
Debian Release: 8.1
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 4.0.4-x86-linode75 (SMP w/8 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages dateutils depends on:
ii libc6 2.19-18

dateutils recommends no packages.

dateutils suggests no packages.

-- no debconf information

ISO weekday numbers: %u differs between 'date' and dateutils (zero-padded), no alternate

Desire to get the ISO day-in-week number. without zero-pad (it's always a single digit in range 1-7). This is possible with date using %u output format, but there does not appear to be any mechanism in dateutils, and the same format confusingly differs between them (where, elsewhere, it strives to maintains consistency):

 $ dateutils.dseq -f %u 2016-04-02
06

 $ date +%u -d 2016-04-02
6

I looked through all the output formats in the man page but could not find one that was not zero-padded. Really, I don't think zero-padding should ever be present anyways, because there's never two digits in the weekday number, so I don't see why it's there.

In fact, canonical ISO dates are always in a format like this: 2004-W53-6 so there's really no way to construct the official ISO date string using dateutils. There's no format specifier to make one of them, so you'd have to build a composite like so:

dateutils.dseq -f %G-W%V-%u 2016-04-02 | sed 's,.\(.\)$,\1,'

which seems to defeat the purpose of dateutils (i.e., not having to shell out for date generation).

Installed from Ubuntu repository but datediff command not found

I installed dateutils with
sudo apt-get install dateutils

The package is listed as installed yet when I run

datediff 2001-02-08 2001-03-02

I get an error that the command datediff is not found.
I tried: ddatediff 2001-02-08 2001-03-02 and get the same error.

How do I run dateutil commands?

Two-digit year dates with dconv produce errors in some cases

Hi.
This script and output illustrates that year "97" produces "1997", but "67" produces "2067". I'd like to see an option to set the difference or absolute value of the year date to handle the situation.

This is from an attempted solution on a forum. I often demonstrate dateutils in solving user date issues on forums.

Thanks ... cheers, drl

#!/usr/bin/env bash

# @(#) s1l  Demonstrate date conversion, dateutils, dconv.

program=dconv
program=dateutils.dconv
# Utility functions: print-as-echo, print-line-with-visual-space, debug.
# export PATH="/usr/local/bin:/usr/bin:/bin"
LC_ALL=C ; LANG=C ; export LC_ALL LANG
pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; }
db() { : ; }
C=$HOME/bin/context && [ -f $C ] && $C $program

FILE=${1-data1}

pl " Input data file $FILE:"
cat $FILE

pl " Expected output:"
cat expected-output.txt

pl " Results:"
input='%d-%b-%y'
pe " Input format is \"$input\""
$program -i "$input" -f '%Y%m%d' -S < $FILE

exit 0

----- output

$ ./s1

Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 3.16.0-4-amd64, x86_64
Distribution        : Debian 8.2 (jessie) 
bash GNU bash 4.3.30
dateutils.dconv dconv 0.3.1

-----
 Input data file data1:
Col1|col2|col3|col4|col5|col6-------col26
1|2|3|10-Nov-67|10-Nov-97|4|5-------100
1|2|3|11-Feb-01|01-Dec-15|4|5-------2000

-----
 Expected output:
Col1|col2|col3|col4|col5|col6-------col26
1|2|3|19671110|19971010|4|5-------100
1|2|3|20010211|20151201|4|5-------2000


-----
 Results:
 Input format is "%d-%b-%y"
Col1|col2|col3|col4|col5|col6-------col26
1|2|3|20671110|19971110|4|5-------100
1|2|3|20010211|20151201|4|5-------2000

Build on OS X

Hi, should this build on OS X (10.8.3)

I'm getting errors with the default gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

So I installed gcc-4.8. I still get errors. Initially the autoreconf -i command puts a random . on line 4 of configure which kills the command. Removing that and using gcc 4.8, I get errors.

The log shows:

conftest.c:4:25: warning: missing terminating " character [enabled by default]
 #define PACKAGE_VERSION "-n
                         ^
conftest.c:5:1: warning: missing terminating " character [enabled by default]
 "
 ^
conftest.c:5:1: error: missing terminating " character
conftest.c:6:24: warning: missing terminating " character [enabled by default]
 #define PACKAGE_STRING "dateutils -n
                        ^
conftest.c:7:1: warning: missing terminating " character [enabled by default]
 "
 ^
conftest.c:7:1: error: missing terminating " character
conftest.c:11:17: warning: missing terminating " character [enabled by default]
 #define VERSION "-n
                 ^
conftest.c:12:1: warning: missing terminating " character [enabled by default]
 "
 ^
conftest.c:12:1: error: missing terminating " character
configure:3273: $? = 1
configure:3311: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "dateutils"
| #define PACKAGE_TARNAME "dateutils"
| #define PACKAGE_VERSION "-n
| "
| #define PACKAGE_STRING "dateutils -n
| "
| #define PACKAGE_BUGREPORT "https://github.com/hroptatyr/dateutils"
| #define PACKAGE_URL ""
| #define PACKAGE "dateutils"
| #define VERSION "-n
| "
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }

See the closing " are on newlines?

If I re-write as:

/* confdefs.h */
#define PACKAGE_NAME "dateutils"
#define PACKAGE_TARNAME "dateutils"
#define PACKAGE_VERSION "-n"
#define PACKAGE_STRING "dateutils -n"
#define PACKAGE_BUGREPORT "https://github.com/hroptatyr/dateutils"
#define PACKAGE_URL ""
#define PACKAGE "dateutils"
#define VERSION "-n"
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}

It compiles fine with gcc confdefs.c

Any ideas?

dateseq inconsistency, implementation leak

As mentioned in issue #27 dateseq A B should be equivalent to

$ seq 0 `datediff A B` | dateadd A

however, using the month iterator it becomes apparent that the sequencing is an iterative process:

$ dseq 2010-01-31 +1mo 2010-05-31

should be:

2010-01-31
2010-02-28
2010-03-31
2010-04-30
2010-05-31

autoreconf fails on Ubuntu 14.04 64bit system (undefined macro: dnl)

The failure is:

% autoreconf -i
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `build-aux'.
libtoolize: copying file `build-aux/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
configure.ac:1: error: possibly undefined macro: dnl
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1

My system:

% uname -a
Linux ZALANDO-04871 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

% lsb_release -a
LSB Version:    core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch:core-4.1-amd64:core-4.1-noarch:security-4.0-amd64:security-4.0-noarch:security-4.1-amd64:security-4.1-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.1 LTS
Release:        14.04
Codename:       trusty

leap year calculation

Hello everybody,

hroptatyr, thanks for the great work on dateutils. I am playing around with it for a few minutes now and I like it already...;-)

Although, I think I found a bug that should be squished, the determination whether a year is a leap year or not.

If you run the following line from bash:

for i in {2000..2100}; do echo dadd $i-02-28 1d; done | bash

you will get the next day after each 28th of february for every year in the range from 2000 to 2100.

What I see from this, is that your code determines that a year is a leap year if it is evenly divisible by the number 4.

As far as I know, this is not the correct definition of a leap year.

To find out whether a year is a leap year sequentially follow the following steps:

  1. precondition: the year is in the Gregorian calendar which started October 15, 1582
  2. if the year is is evenly divisible by 4, it IS a leap year
  3. if the year is is evenly divisible by 100, it IS NOT a leap year (although it is evenly divisible by 4)
  4. if the year is is evenly divisible by 400, it IS a leap year (although it is evenly divisible by 100)

Here are some sources to check this:
http://en.wikipedia.org/wiki/Gregorian_calendar
http://en.wikipedia.org/wiki/Leap_year

Kind regards,
André Kaldenhoven

Problem with dadd, when input month is January and duration is -1y/-12m/etc.

When I use dadd with a January date and subtract one year, the result is off by one year:

% dseq 2012-01-01 +1d 2012-01-31 | dadd -1y
2010-01-01
2010-01-02
2010-01-03
2010-01-04
2010-01-05
2010-01-06
2010-01-07
2010-01-08
2010-01-09
2010-01-10
2010-01-11
2010-01-12
2010-01-13
2010-01-14
2010-01-15
2010-01-16
2010-01-17
2010-01-18
2010-01-19
2010-01-20
2010-01-21
2010-01-22
2010-01-23
2010-01-24
2010-01-25
2010-01-26
2010-01-27
2010-01-28
2010-01-29
2010-01-30
2010-01-31

Every other month seems to be okay:

% dseq 2012-02-05 +1m 2012-12-05 | dadd -1y
2011-02-05
2011-03-05
2011-04-05
2011-05-05
2011-06-05
2011-07-05
2011-08-05
2011-09-05
2011-10-05
2011-11-05
2011-12-05

The problem persists with different starting years, and with the duration -12m.

% dadd 2012-01-25 -12m
2010-01-25
% dadd 1998-01-25 -12m
1996-01-25

Oddly, it does not occur with the duration -365d.

% dadd 2012-01-25 -365d
2011-01-25

I'm using dateutils 0.1.8 on Gentoo 3.2.1, installed from Portage.

'today hh:mm' produces error "cannot make sense of"

Hello again. I'm not sure if weather this is a bug or a feature, or maybe I'm just doing it wrong, but specifying a time of today produces the following output from ddiff.

ddiff: cannot make sense of `today ??:??' using the given input formats

Here is the actual command line I'm using.

$ ddiff --from-zone $TZ -f '%H:%M:%S' now 'today 17:39'

Specifying today's date as 2014-09-14 does work. It appears to be something with the 'today' functionality itself.

I recompiled from the latest git to see if it was something in the older version I was using, but 0.3.0.git39.79657eb is producing the same result.

Thanks.

dateadd ignoring day information

This is a very useful project. Thanks.
This problem is about how dadd responds to day information.

dateutils.dadd 00:00:00:00 1d4h5m4s
gives output as
04:05:04

The information about 1 day is ignored altogether. Any solution.

dseq 'fixes' incorrect input, rather than throwing an error

An example:

$ dseq 2013-02-30 2013-02-30
2013-02-28

Not sure if you'd like to consider this an error and fail, but in scripts it could cause problems, where the user puts in a false date, and the script churns out fine-looking output, just for the wrong day(s).

dconv --from-zone and --zone segmentation faults on Mac OSX Yosemite (10.10.3)

Below is an example of the problem copy-pasted-from my terminal:

$ echo 2012-03-01T07:05:06 | dconv --from-zone=EDT
2012-03-01T07:05:06

$ echo 2012-03-01T07:05:06 | dconv --from-zone=UTC
Segmentation fault: 11

$ echo 2012-03-01T07:05:06 | dconv --from-zone America/New_York
Segmentation fault: 11

I tried compiling with both the Mac OS default gcc and GNU gcc 4.6 from MacPorts but it doesn't seem to make a difference wrt this issue.

Possible to change binary command prefix?

So, this falls the intersection of "all the good names are taken" and "flat namespaces are kinda insane", but we realised that the dtest command conflicts with a command of the same name already in Red Hat Enterprise Linux for testing the "dapl" library from openfabrics. Now, arguably, it'd make a lot more sense for that command to be named something less generic, but I don't know how much traction I'd get there. I can also ignore that and just package this for Fedora instead of for Fedora + EPEL, but that seems a little sad.

How do you feel about changing the d prefix of these commands to date, so datetest, dateconv, and etc., either just for Fedora/EPEL or as a universal "hey, we weren't 1.0 yet anyway" change? I appreciate the convenience of shorter names, but seems like putting "date" there would help with the current minor conflict and avoid potential other conflicts with other utilities around any future thing which happens to start with d.

Not a huge deal but figured I'd check — thanks!

No format spec for non-zero padded day of month

Some logs contain non-zero padded dates (something like Oct 1 12:05:00).

As of dateutils version 0.4 there is no format spec for day of month that support non-zero padded dates. Available %d expect zero-padded date with two digits. So dconv is unable to convert such logs

Test case:

Properly handling 2 digits day of month

dconv --input-format "%b %d %H:%M:%S" --format "%F %T" "Oct 10 12:05:00"
2016-10-10 12:05:00

Error on white space padded sindle digit day of month

dconv --input-format "%b %d %H:%M:%S" --format "%F %T" "Oct 1 12:05:00"
dconv: cannot make sense of `Oct 1 12:05:00' using the given input formats

0.3.2 breaks crossbuild

Hello!

dateutils-0.3.2 breaks crossbuild.

configure output when building for armv7 on x86_64:

configure: WARNING: unrecognized options: --with-libtool-sysroot
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-linux-gnueabihf7-strip... arm-linux-gnueabihf7-strip
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for arm-linux-gnueabihf7-icc... arm-linux-gnueabihf7-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-linux-gnueabihf7-gcc accepts -g... yes
checking for arm-linux-gnueabihf7-gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of arm-linux-gnueabihf7-gcc... gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... arm-unknown-linux-gnueabihf7
checking how to run the C preprocessor... arm-linux-gnueabihf7-cpp
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking whether C compiler accepts -std="gnu11"... yes
checking whether C compiler can understand anonymous structs and unions... yes
checking for preferred CC std... -std=gnu11
checking whether C compiler can initialise anonymous structs and unions... yes
checking whether C compiler accepts -Wmissing-field-initializers... yes
checking whether C compiler can initialise structs and unions in a sloppy way... no
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... (cached) no
checking for user provided CFLAGS/EXTRA_CFLAGS...  -O2 -pipe -fstack-protector-strong -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard   
checking whether C linker accepts -XCClinker -foo... no
checking whether C linker accepts -Xlinker -foo... no
checking whether C compiler accepts -g... yes
checking whether C compiler accepts -g3... yes
checking for dbx... no
checking for gdb... no
checking for sdb... no
checking whether C compiler accepts -ftime-report... no
checking whether C compiler accepts -fmem-report... no
checking whether C compiler accepts -fvar-tracking... no
checking whether C compiler accepts -save-temps... yes
checking for preferred debugging flags... 
checking whether C compiler accepts -Wall... yes
checking whether C compiler accepts -qinfo... no
checking whether C compiler accepts -Wextra... yes
checking whether C compiler accepts -Wsign-compare... yes
checking whether C compiler accepts -Wno-char-subscripts... yes
checking whether C compiler accepts -Wundef... yes
checking whether C compiler accepts -Wpacked... yes
checking whether C compiler accepts -Wpointer-arith... yes
checking whether C compiler accepts -Wshadow... yes
checking whether C compiler accepts -Wmissing-declarations... yes
checking whether C compiler accepts -Wmissing-prototypes... yes
checking whether C compiler accepts -Wbad-function-cast... yes
checking whether C compiler accepts -Wcast-qual... yes
checking whether C compiler accepts -Wcast-align... yes
checking whether C compiler accepts -Wno-switch... yes
checking whether C compiler accepts -Wunused-function... yes
checking whether C compiler accepts -Wunused-variable... yes
checking whether C compiler accepts -Wunused-parameter... yes
checking whether C compiler accepts -Wunused-value... yes
checking whether C compiler accepts -Wunused... yes
checking whether C compiler accepts -Wmaybe-uninitialized... yes
checking whether C compiler accepts -Wnopragma... no
checking whether C compiler accepts -fdiagnostics-show-option... yes
checking whether C compiler accepts -Wunknown-pragmas... yes
checking whether C compiler accepts -Wuninitialized... yes
checking whether C compiler accepts -Wreorder... no
checking whether C compiler accepts -Wdeprecated... yes
checking whether C compiler accepts -Wno-parentheses... yes
checking whether C compiler accepts -Wcheck... no
checking whether C compiler accepts -Wstrict-aliasing... yes
checking whether C compiler accepts -w3... no
checking whether C compiler accepts -diag-disable 10237... no
checking whether C compiler accepts -wd 10237... no
checking whether C compiler accepts -diag-disable 2102... no
checking whether C compiler accepts -wd 2102... no
checking whether C compiler accepts -debug inline-debug-info... no
checking whether C compiler accepts -diag-enable remark,vec,par... no
checking whether C compiler accepts -Wunsuffixed-float-constants... yes
checking for preferred warning flags... -Wall -Wextra -Wsign-compare -Wno-char-subscripts -Wundef -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wbad-function-cast -Wcast-qual -Wcast-align -Wno-switch -Wunused-function -Wunused-variable -Wunused-parameter -Wunused-value -Wunused -Wmaybe-uninitialized -fdiagnostics-show-option -Wunknown-pragmas -Wuninitialized -Wdeprecated -Wno-parentheses -Wstrict-aliasing -Wunsuffixed-float-constants
checking whether C compiler accepts -ipo... no
checking whether C compiler accepts -no-prec-div... no
checking whether C compiler accepts -nopie... no
checking whether C compiler accepts -static-intel... no
checking whether C compiler accepts -static-libgcc... yes
checking whether C compiler accepts -intel-extensions... no
checking for preferred CFLAGS...  -O2 -pipe -fstack-protector-strong -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard      -Wall -Wextra -Wsign-compare -Wno-char-subscripts -Wundef -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wbad-function-cast -Wcast-qual -Wcast-align -Wno-switch -Wunused-function -Wunused-variable -Wunused-parameter -Wunused-value -Wunused -Wmaybe-uninitialized -fdiagnostics-show-option -Wunknown-pragmas -Wuninitialized -Wdeprecated -Wno-parentheses -Wstrict-aliasing -Wunsuffixed-float-constants  -static-libgcc 
configure:
If you wish to APPEND your own flags you want to stop here and rerun the
configure script like so:
  configure EXTRA_CFLAGS=<to-be-added-flags>

If you wish to OVERRIDE these flags you want to stop here too and rerun
the configure script like this:
  configure CFLAGS=<the-definitive-flags-I-want>

You can always override the determined CFLAGS, partially or totally,
using
  make -C <directory> CFLAGS=<your-own-flags> target
or
  make CFLAGS=<your-own-flags> target
respectively

checking for arm-linux-gnueabihf7-gcc -std=gnu11 option to accept ISO C99... none needed
checking for stipulated version files... configure: error: in `/builddir/dateutils-0.3.2':
configure: error: cannot run test program while cross compiling
See `config.log' for more details
=> ERROR: dateutils-0.3.2_1: failed to run do_configure() at line 7.

workaround:

sed -i "/^## check\/generate version files/,/^## check for byteorder utils/d" configure
cat > version.mk <<EOF
VERSION = 0.3.2
PACKAGE_VERSION = \$(VERSION)
PACKAGE_STRING = \$(PACKAGE) \$(VERSION)
EOF

dadd segaults on MacOSX

I see many segfaults when running the test suite (not only dadd). Seems option --zone is always involved.

localhost:dateutils-0.2.4-26-gd50dd27c svp$ gdb src/dadd
GNU gdb 6.3.50-20050815 (Apple version gdb-1515) (Sat Jan 15 08:33:48 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .. done

(gdb) run  +1d23h -z Europe/Berlin
Starting program: /Users/svp/tmpsrc/dateutils-0.2.4-26-gd50dd27c/src/dadd +1d23h -z Europe/Berlin
Reading symbols for shared libraries +. done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000100068000
0x00000001000049c3 in __conv_zif [inlined] () at /Users/svp/tmpsrc/dateutils-0.2.4-26-gd50dd27c/lib/tzraw.c:207
207                     tgt->trs[i].tr = be32toh(src->trs[i].tr);
(gdb) bt
#0  0x00000001000049c3 in __conv_zif [inlined] () at /Users/svp/tmpsrc/dateutils-0.2.4-26-gd50dd27c/lib/tzraw.c:207
#1  0x00000001000049c3 in __copy_conv [inlined] () at /Users/svp/tmpsrc/dateutils-0.2.4-26-gd50dd27c/lib/tzraw.c:258
#2  0x00000001000049c3 in zif_open (file=) at tzraw.c:331
#3  0x000000010001a9ac in main (argc=4, argv=) at dadd.c:277

ISO years: %G undocumented, and %Y may not translate correctly with %V

was trying to get the Vulgar years/months/days for a full ISO year (to prepopulate some datafiles), using dseq, but there is no way to do it without %G (documented in date.1 but not present in dseq.1):

 $ dateutils.dseq -i %Y%V%u -f '%Y %m %d %V %u' 20160101 20170101 | head
2015 01 04 01 01
2015 01 05 01 02
2015 01 06 01 03
2015 01 07 01 04
2016 01 08 01 05
2016 01 09 01 06
2016 01 10 01 07
2016 01 11 02 01
2016 01 12 02 02
2016 01 13 02 03

These are incorrect (discontiguous). Instead %G is needed:

 $ dateutils.dseq -i %Y%V%u -f '%G %m %d %V %u' 20160101 20170101 | head
2016 01 04 01 01
2016 01 05 01 02
2016 01 06 01 03
2016 01 07 01 04
2016 01 08 01 05
2016 01 09 01 06
2016 01 10 01 07
2016 01 11 02 01
2016 01 12 02 02
2016 01 13 02 03

The output is correct / as intended. So %G should be documented. However, in this case I believe the input parsing is wrong, because the date 20160101 as %Y%V%u does not make sense, it should return an error due to ambiguity (mix of vulgar and ISO) and insist on %G%V%u as input format. FWIW, these commands have identical outputs:

dateutils.dseq -i %Y%V%u -f '%G %m %d %V %u' 20160101 20170101
dateutils.dseq -i %G%V%u -f '%G %m %d %V %u' 20160101 20170101

(Note that I'm using the Debian version (0.3.1) but I scanned the v0.3.1..v0.3.5 git log and didn't find any relevant changes (and also %G itself was only present in the test suite for master branch))

dateround does nothing with `%s` input

This works:

$ echo '2016-01-01 12:12:12' | dateround -i '%F %T' /15s
2016-01-01T12:12:15

This doesn't:

$ echo '2016-01-01 12:12:12' | strptime -i '%F %T' -f '%s' | dateround -i '%s' /15s
2016-01-01T12:12:12

tzmap tests fail, segfault

All the 4 tests added in 18688fb are failing on current openSUSE_Factory, for example
$ export TZMAP_DIR=test
$ ./src/dadd --zone dummy:XETR --from-zone Europe/London 2012-03-04T12:04:11 +1h
#0 0x0000000000404118 in __assoc (key=key@entry=0x7f016e23b856 <error: Cannot access memory at address 0x7f016e23b856>, al=0x62b5a0 , al=0x62b5a0 ) at alist.c:58
#1 0x00000000004041f7 in alist_assoc (al=al@entry=0x62b5a0 , key=key@entry=0x7f016e23b856 <error: Cannot access memory at address 0x7f016e23b856>) at alist.c:113
#2 0x0000000000403ed0 in __io_zone (spec=0x7f016e23b856 <error: Cannot access memory at address 0x7f016e23b856>) at dt-io-zone.c:119
#3 dt_io_zone (spec=0x7f016e23b856 <error: Cannot access memory at address 0x7f016e23b856>) at dt-io-zone.c:162
#4 0x00000000004014d9 in main (argc=7, argv=0x7fffadddb468) at dadd.c:245

Looks like tzm_find() is broken.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.