[flang-commits] [flang] [llvm] [clang] [clang-tools-extra] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

Yi Wu via flang-commits flang-commits at lists.llvm.org
Wed Nov 15 09:09:31 PST 2023


PAX-12-WU wrote:

update based on: 
https://github.com/llvm/llvm-project/pull/70917#discussion_r1393878064 Emit a Fortran runtime failure (instead of `assert`)
https://github.com/llvm/llvm-project/pull/70917#discussion_r1393905238 Space filling

`fdate` now produce the same result on flang, compare to fortran, where
If the length is too short to fit completely, blank return.
```fortran
  character(20) :: string
  call fdate(string)
  write(*, *) string, "X"
```
```bash
$ ../build-release/bin/flang-new test.f90 
$ ./a.out 
                      X
```
If length if larger than it requires(24), fill the rest of buffer space.
```fortran
  character(30) :: string
  call fdate(string)
  write(*, *) string, "X"
```
```bash
$ ../build-release/bin/flang-new test.f90 
$ ./a.out 
 Wed Nov 15 16:59:13 2023      X
```
The length value is hardcoded, because:
```c++
  // Day Mon dd hh:mm:ss yyyy\n\0 is 26 characters, e.g.
  // Tue May 26 21:51:03 2015\n\0
```

https://github.com/llvm/llvm-project/pull/71222


More information about the flang-commits mailing list