Open zoziha opened 3 years ago
The codes of John Burkardt all contain a timestamp subroutine (GPL-licensed) with fixed format:
On the other hand the M_time
module has a formatted time function:
Here are some options from other languages:
>>> Dates.format(now(), "HH:MM")
"13:18"
dt.strftime("%A, %d. %B %Y %I:%M%p")
'Tuesday, 21. November 2006 04:30PM'
fprintf('This message is sent at time %s\n', datestr(now,'HH:MM:SS'))
Some open issues to discuss are:
integer :: dat(8)
returned by intrinsic date_and_time
, other )Perhaps this is a bad idea, but I wonder if there is any advantage to write into the format string directly?
integer :: dat(8)
call date_and_time(values=dat)
write(*,fmtdate(dat))
! vs
write(*,'(A)') datestr(dat)
Somewhat related is #106.
Rather than implementing a specific (fixed-format) time stamp, I recommend simply providing a binding to C strftime
, which is a much more versatile solution with less code.
The Forlab implementation looks like it was adapted from John Burkardt's. timestamp()
. Should probably note that in the Forlab LICENSE file.
The Forlab implementation looks like it was adapted from John Burkardt's.
timestamp()
. Should probably note that in the Forlab LICENSE file.
Thanks for reminding. I have only come into contact with open source code not long ago, and have not been very familiar with open source licenses. If it is a relatively short function, do I need to follow its license because I changed it? Can a project simply combine multiple open source licenses?
do I need to follow its license because I changed it?
Absolutely. Adopting the same interface is okay, I believe, but you have to respect the license when it comes to the implementation. That's why looking too closely at GPL code for the standard library isn't such a good idea IMO. The standard library is aiming for MIT or BSD licensing isn't it?
I'm very sorry about that, I didn't realize this before. John Burkardt/timestamp was a subroutine, but now forlab/times_stamp becomes a module function. Isn’t it OK? I made this git push today, can I remove this license issue by just deleting this LGPL code git push? (I am scared😢, I just deleted it just now.)
How about simply creating a fixed format time_stamp
function to start stdlib_time
. It's simple, but it's also useful.
This reminds people that there is still some work in stdlib_time
, remember to improve stdlib_time
. 😂
How about simply creating a fixed format
time_stamp
function to startstdlib_time
. It's simple, but it's also useful.
NAG has a simple function called nagf_time_date_array_string that takes as input an integer :: itime(7)
(kind of similar to the return value of subroutine date_and_time
and returns a formatted string.
If we can reach an agreement on the name and format I'm fine to have this. But in general the solution of @milancurcic will be more helpful. A downside of c_strftime
is one needs to size the buffer correctly. If we could have function which returns a character(len=:), allocatable
and accepts a custom format it would be more convenient. Then everyone can have the format they likes best and write a simple wrapper function
function nowstr()
character(len=:), allocatable :: nowstr
integer :: vals(8)
call date_and_time(values=vals)
! %c returns a date and time representation like:
! Sun Aug 19 02:56:02 2012
nowstr = fstrftime('%c',vals)
end function
I would have use for stdlib provided derived type to express a time stamp since it would allow to bridge TOML Fortran and stdlib. This would allow to directly retrieve TOML documents as stdlib hash map including date time values from the TOML document as stdlib compatible derived type.
A (simple) time stamp is already implemented in stdlib_logger
. Could it be an idea to move it to e.g., stdlib_time
and discuss its API and implementation based on the different needs?
Description For example, the Go language standard library has a time library golang/time, and
stdlib
also has a time module requirement. Is it possible to provide basic time module capabilities forstdlib
. Startstdlib_time
module by implementing atime_stamp
function ?Prior Art
Fortran Time Packages
Related Issues https://github.com/fortran-lang/stdlib/issues/1 and https://github.com/fortran-lang/stdlib/issues/106