GnuCOBOL offers a lot of FUNCTIONS for managing DATE and TIME.
but ... what do you think is the simplest way to display the following three data:
- the time at the start of the program
- the time that passes as time passes
- the difference in number of seconds between the two previous times as time passes 1, 2 3, .... 1326, 1327, etc et
- the difference in format hh:mm:ss between the two previous times as time passes 1
Last edit: Eugenio Di Lorenzo 2021-12-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you are still interested in time durations, here are a couple of copy books I use in some of my programs. They are and expansion to code in the sample DEMOMATH.COB.
Basically you save a start time like when the program starts or the beginning of some event in your code, then later perform the routine and get the duration back in hours, minutes and seconds.
I also included a program that I used to test the copy books.
First of all, thank you a lot for sharing your solution and your source code. this I think should be the spirit of all fans of open source code and free software code.
Thanks again, really appreciated.
Going into the merits of the problem, I can say that I too had found an "old-fashioned" solution.
I am attaching an example below.
But ... the main purpose of this post was to verify if there is a simpler solution through the use of intrinsic functions. For example we have many "old-fashioned" solutions for calculations between dates. A lot of source code has been written over time for this but with the intrinsic functions everything has become a lot simpler.
For calculations between times, on the other hand, I have not yet seen if the intrinsic functions can be useful for this.
Ciao.
GnuCOBOL offers a lot of FUNCTIONS for managing DATE and TIME.
but ... what do you think is the simplest way to display the following three data:
- the time at the start of the program
- the time that passes as time passes
- the difference in number of seconds between the two previous times as time passes 1, 2 3, .... 1326, 1327, etc et
- the difference in format hh:mm:ss between the two previous times as time passes 1
Last edit: Eugenio Di Lorenzo 2021-12-24
A quick answer, just my first thoughts, no actual testing involved.
I'd go with
SECONDS-PAST-MIDNIGHT
(taking care for the possible date swap, of course)Isn't that the same as the one above?
FORMATTED-TIME
with the seconds already availableLast edit: Simon Sobisch 2021-12-24
If you are still interested in time durations, here are a couple of copy books I use in some of my programs. They are and expansion to code in the sample DEMOMATH.COB.
Basically you save a start time like when the program starts or the beginning of some event in your code, then later perform the routine and get the duration back in hours, minutes and seconds.
I also included a program that I used to test the copy books.
You may find part of the code useful.
First of all, thank you a lot for sharing your solution and your source code. this I think should be the spirit of all fans of open source code and free software code.
Thanks again, really appreciated.
Going into the merits of the problem, I can say that I too had found an "old-fashioned" solution.
I am attaching an example below.
But ... the main purpose of this post was to verify if there is a simpler solution through the use of intrinsic functions. For example we have many "old-fashioned" solutions for calculations between dates. A lot of source code has been written over time for this but with the intrinsic functions everything has become a lot simpler.
For calculations between times, on the other hand, I have not yet seen if the intrinsic functions can be useful for this.
Ciao.
If you are on a Linux system, you might consider using the 'time' command. It gives output like:
jack@ps:~$ time date
Mon 07 Feb 2022 08:29:44 PM EST
real 0m0.002s
user 0m0.001s
sys 0m0.001s
jack@ps:~$