LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   A program to compute number of days between two dates? (https://www.linuxquestions.org/questions/slackware-14/a-program-to-compute-number-of-days-between-two-dates-4175454050/)

Bazzaah 03-14-2013 05:50 PM

Quote:

Originally Posted by stf92 (Post 4911447)
Hi:

I mean, does slackware include one in his distributions? In the affirmative case I would like to know its name.

It's a trivial calculation in LibreOffice.

Enter the two dates, then subtract the earlier date from today's date.

83251 days, some 228 years.

Not sure if your objective is to use a cli function specifically or just learn how to do something, but if you just need to make the calculation, LibreOffice is a very easy option.

allend 03-14-2013 06:39 PM

Quote:

Some of us will be tempted to forecast next Slackware release's date from the average delay between two releases, I guess
Couldn't help myself! My prediction based on the past data is a release between April 17 2013 and February 11 2014 with a 99.7% certainty.

w1k0 03-14-2013 07:05 PM

allend,

It seems I’m slightly more cautious than you because my guess which bases on the previous results is: no less than 7 days and no more than 2 years after Slackware 14.0 release:

date --date="September 28, 2012 +7 days" +"%Y-%m-%d"
Code:

2012-10-05
date --date="September 28, 2012 +2 years" +"%Y-%m-%d"
Code:

2014-09-28
Certainty: 99.99%.

stf92 03-14-2013 07:08 PM

Quote:

Originally Posted by Bazzaah (Post 4911769)
It's a trivial calculation in LibreOffice.

Enter the two dates, then subtract the earlier date from today's date.

83251 days, some 228 years.

Not sure if your objective is to use a cli function specifically or just learn how to do something, but if you just need to make the calculation, LibreOffice is a very easy option.

My sister left on vacations some time ago, not before telling me she would come back in about three weeks. Knowing the date of departure, and today's date, I wanted to know in how many days I should expect her arrival. That was all. But firs I had to do 28 + 14 to find today's date with respect to february (assuming february is infinitely long), and I wondered if there could be some linux command ad hoc. The answer is just 'date'. It does all the work. By the way I found a new linux command: calc.

w1k0 03-14-2013 07:13 PM

Quote:

Originally Posted by stf92 (Post 4911802)
By the way I found a new linux command: calc.

cal

psionl0 03-14-2013 09:25 PM

Quote:

Originally Posted by allend (Post 4911786)
Couldn't help myself! My prediction based on the past data is a release between April 17 2013 and February 11 2014 with a 99.7% certainty.

However you look at the data, 520 days should be considered an outlier:
Code:

  0 -  49:*
 50 -  99:**
100 - 149:*******
150 - 199:*****
200 - 249:*****
250 - 299:******
300 - 349:**
350 - 399:***
400 - 449:
450 - 499:
500 - 549:*


w1k0 03-14-2013 10:03 PM

Quote:

Originally Posted by psionl0 (Post 4911884)
However you look at the data, 520 days should be considered an outlier:
Code:

  0 -  49:*
 50 -  99:**
100 - 149:*******
150 - 199:*****
200 - 249:*****
250 - 299:******
300 - 349:**
350 - 399:***
400 - 449:
450 - 499:
500 - 549:*


Looking at your analysis it seems that the most probable is the range 400–499.

date --date="September 28, 2012 +400 days" +"%Y-%m-%d"
Code:

2013-11-02
date --date="September 28, 2012 +499 days" +"%Y-%m-%d"
Code:

2014-02-09
It isn’t my prediction.

I prefer 99.99% of the practical certainty as I wrote about that in the post 33.

(It seems to me that the term “practical certainty” was coined by Descartes.)

allend 03-14-2013 11:08 PM

Quote:

However you look at the data, 520 days should be considered an outlier:
This is balanced by the lower extreme of 7 days. Statistically speaking, there is no valid reason to drop either or both data points.

There is also a trend to a longer time between releases.

Didier Spaier 03-15-2013 02:56 AM

Next Slackware release will occur sometimes between now and never with 100% certainty.

No algorithm was hurt to make this prediction.

psionl0 03-15-2013 04:29 AM

Quote:

Originally Posted by w1k0 (Post 4911909)
Looking at your analysis it seems that the most probable is the range 400–499.

Not one release took 400-499 days. The dot frequency chart suggests that the time between releases is more like 200 + 200 days.

Quote:

Originally Posted by allend (Post 4911937)
This is balanced by the lower extreme of 7 days. Statistically speaking, there is no valid reason to drop either or both data points.

There is also a trend to a longer time between releases.

You're right. If you ignore the two outliers, then a straight line regression would give a high correlation. From visual inspection we would be looking at 200 - 400 days.
Code:

|                                    *
+
|
|
|
|
+                  ----------------------
|                    *      *
|                      *
|                                  *
|
+                              *
|                      *  *  *  *
|          *                    *
|              *    *
|                          **  *
+                *---------------------
|      * *                *
|                  *
|  * *          *
|*  *      *  **
+ *      *
|
|    *
|
|
+------------------*--------------------


w1k0 03-15-2013 07:44 AM

16 occurrences in the range 0–199 and 17 occurrences in the range 200–399. So none of these ranges is privileged. On the other hand the older releases periods are usually shorter (or very short) and the newer releases periods are usually longer (or very long). So there’s the tendency to prolong these periods. The next range after the mentioned ones is 400–499 and it’s empty so far. According to the overall tendency sooner or later some releases will appear in that range as well. I assume that it’ll happen rather sooner than later. That was my point from post #37.

***

In fact to be fair I should take into consideration the range of the equal size as the previous ones: 400–599. It’s almost empty (one occurrence). Sooner or later more releases will appear here. I say: rather sooner than later.

eloi 03-15-2013 09:13 AM

Quote:

Originally Posted by Bazzaah (Post 4911769)
It's a trivial calculation in LibreOffice.

Enter the two dates, then subtract the earlier date from today's date.

83251 days, some 228 years.

Not sure if your objective is to use a cli function specifically or just learn how to do something, but if you just need to make the calculation, LibreOffice is a very easy option.

Totally agree. Each time someone asks me how to calculate days
between 1784 and today (yesterday an old lady at greengrocer's
asked me exactly that), to calculate the beauty of a Leonardo
painting or make some prediction based in numerology, like "When
a big asteroid will impact with Earth and put an end to all this
idiocy?", I advice to install LibreOffice. Compile it from
source for a better result.

(Just to remember people that Microsoft Office Suite is
indispensable, essential, irreplaceable software).

neymac 03-15-2013 12:27 PM

Nice program, troyaine! Thanks.

neymac 03-15-2013 12:43 PM

Quote:

Originally Posted by GazL (Post 4911616)
Code:

gazl@ws1:/var/tmp$ ./days.sh 2013 3 14
734940 complete since the beginning (start of 1AD)
gazl@ws1:/var/tmp$ ./days.sh 1784 4 7
651324 complete since the beginning (start of 1AD)
gazl@ws1:/var/tmp$ echo $(( 734940 - 651324 ))
83616


Using the C program made by troyaine I got 734942 days from 01/01/0001 to 03/14/2013...???
What is the catch?

qweasd 03-15-2013 12:44 PM

2 Attachment(s)
The red line is the trend obtained from simple linear regression. The X axis is voodoo, and there is no reason to suppose a linear model would work here anyway, but if it did, then the next release is some 340 days after 14.0.


All times are GMT -5. The time now is 07:44 AM.