Here are a few programs that tell "the age at", "the time since", "the time between ... and ..." and so on.
Here is how it works. The user inputs either one or two dates:
This program is in C and so compiled into a binary. It has a text interface that asks for input only after invocation.
A better solution would be to retrieve the arguments directly from the shell invocation line (following the executable/tool name) instead of doing it in-house. Because if so, then the program can be integrated in shell computation (i.e., it would become a tool) - also, so that deeply wired finger-habits can be used for editing, which is instantly frustrating if they cannot. (To arrange this is not difficult to do in C: the reason I don't change it is because I now prefer another tool for this.)
This program also does not include months and days in its output, because it was intended to answer the question how old a person were (e.g., a boxer, at the time of a particular fight).
This program is by far the slowest program to maintain (compared to those who follow) as C is a compiled language, with a syntax that despite good, is not specialized for any particular task.
This is a zsh wrapper to the tool ddiff. (It is probably in your repositories already as "dateutils".)
Because this is a mere interface it cannot take full credit for solving the problem. Yes, it relies on another tool. But what is the harm in that? On the contrary, it is virtue not reinventing the wheel but instead adapting the already existing wheel to fully fit your purposes. Whenever so, you only have to bring the spoke key, not the entire toolbox.
For example, this program is fun when you meet a person that you have not seen in some time: instead of playing the stupid game of estimating how much time has passed - is it three years? four? five? - instead of this, simply mail him/her the next day with the exact data: "That happened 3 years, 9 months, and 4 days ago." :)
The reason I wrote it was to get a more exact piece of information than the C version, and to have it fully integrated in the shell (as either a shell function or a script). The current version is a function.
This version is the most flexible, and the most robust, since it involves a powerful tool that has many options and is maintained in the stainless-steel FOSS-bazaar way.
This is an Emacs Lips, or Elisp program. LISP is often described as a functional language even though you can do whatever you want whit it. As for this program, it adheres to functional programming principles, though the purpose of such paradigms and models is to make us understand in general rather than instructions what to do specifically. To illustrate, if this program is compared to the C ditto and the zsh wrapper, I do not see a big difference along paradigmic lines.
This program must be invoked from/with Emacs. From the command-line, it can be arranged with the "--batch" Emacs option. (To simplify access, again a zsh or otherwise shell wrapper comes to mind.)
The result is as good as any, only it does not output the number of months that has passed. Instead, it might say: 4 years, 339 days.
Back to the main page.