# WIN32Ada - inconsistent results with time data of files

**URL:** https://forum.ada-lang.io/t/win32ada-inconsistent-results-with-time-data-of-files/4769
**Category:** General
**Created:** [September 23, 2026, 9:05am UTC](https://forum.ada-lang.io/t/win32ada-inconsistent-results-with-time-data-of-files/4769 "2026-09-23T09:05:13Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![RobG9876](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/robg9876/32/663_2.png) [@RobG9876](https://forum.ada-lang.io/u/RobG9876)
#### Post date: [September 23, 2026, 9:05am UTC](https://forum.ada-lang.io/t/win32ada-inconsistent-results-with-time-data-of-files/4769/1 "2026-09-23T09:05:13Z")

</div>

Hello all,  
I am having some small challenges getting file time stamps

Platform: Windows10/11, 64 bit OS and processor.  
Win32ada 25.0.0

In Windows files have 3 time properties, access time, creation time and modification time.

Short version: How can get the correct file times?

(much) longer version:  
Using the WIN32Ada interface there are (at least) 2 ways of getting these times: Win32.crt.Stat.Stat, which returns a struct\_stat record; and Win32.crt.Io.findfirst which returns a findata\_t record. Both records have 3 time fields, of type Win32.crt.Types.time\_t, representing the nr of second since EPOCH (01-jan-1970 00:00:00). In Win32 time\_t is a 32-bit type, so for sure it will have a year 2038 problem if left unchanged.

And then there are Ada.Directories.Modification\_Time which return Ada.Calendar.Time and GNAT.Os\_Lib.File\_Time\_Stamp which returns GANT.OS\_Lib.OS\_Time

When I use these functions and compare them to the time stamps of a file in its property sheet the result do not agree  
Time stamps according to property sheet:

- created : 18-Sep-2026 18:02:36
- modified: 12-Nov-2025 17:50:44
- accessed: 16-Sep-2026 18:02:36

Time stamp according Ada.Directories.Modification\_Time:

- modified: 12-Nov-2025 17:50:44 ==\> agrees with file property sheet

Time stamp according GNAT.OS\_Lib.File\_Time\_Stamp:

- time stamp: 12-Nov-2025 16:50:44 ==\> agrees with file property sheet modification time, given the time zone

Time stamps according Win32.Crt.Stat.Stat:

- created : 12-Nov-2025 17:50:44 ==\> is the modified time in the property sheet
- modified: 01-Jan-1970 00:00:00 ==\> no match what so ever
- accessed: 21-Sep-2026 16:54:41 ==\> no match what so ever  
Online search for the relevant C documentation on stuct stat I can’t find any agreement on the order of elements

Time stamps according Win32.Crt.Io.findfirst:

- created : 01-Jan-1970 09:05:58 ==\> no match what so ever
- modified: 01-Jan-1970 00:00:00 ==\> no match what so ever
- accessed: 18-Sep-2026 17:02:36 ==\> matches created in file property sheet, given the time zone  
Furthermore, in the ‘name’ field (type Char260) the first 16 (or so) elements are bogus; and the reported file size is also incorrect. The results suggest a misalignment with the actual C implementation.

So, how come the Win32ada values are way off?  
And how can I get the correct values for the file time stamps?

(Sorry for the amount of text)

---

<div class="post-metadata">

### Author: ![dmitry-kazakov](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/dmitry-kazakov/32/522_2.png) [@dmitry-kazakov](https://forum.ada-lang.io/u/dmitry-kazakov)
#### Post date: [September 23, 2026, 9:49am UTC](https://forum.ada-lang.io/t/win32ada-inconsistent-results-with-time-data-of-files/4769/2 "2026-09-23T09:49:22Z")

</div>

> [@RobG9876](#):
>
> Short version: How can get the correct file times?

Either use native Windows API or else the Ada Standard Library. If unsure check the standard library implementation source.

Do not use POSIX / UNIX / Borland layers, they are garbage both logically and semantically. On top of that MS never cared about them. I vaguely remember that some of the dozens functions starting a thread actually leak memory. Morale: see above.

**P**. **S**. Win32Ada is not really necessary. First of all it is far from being complete. Secondly, you can pretty easily call Win32 API directly using the stdcall convention and remembering that Windows’ W-calls are UTF-16, which normally would be UCS-2 = Wide\_String.

---

<div class="post-metadata">

### Author: ![RobG9876](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/robg9876/32/663_2.png) [@RobG9876](https://forum.ada-lang.io/u/RobG9876)
#### Post date: [September 23, 2026, 2:04pm UTC](https://forum.ada-lang.io/t/win32ada-inconsistent-results-with-time-data-of-files/4769/3 "2026-09-23T14:04:23Z")

</div>

Note that the ada standard library gives me only the modification time (Ada.Directories.Modification\_Time). I want the accessed and creation times as well.

Using the native API seems doable.

That leaves the question on which struct layout to use. For the C stat struct there are numerous disagreeing definitions. Is the info in the [MS Learn site](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/stat-functions?view=msvc-170) correct? Especially the field order is complete different compared to what can be found on other websites (and in win32ada where the call is directly to the native API)

---

<div class="post-metadata">

### Author: ![dmitry-kazakov](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/dmitry-kazakov/32/522_2.png) [@dmitry-kazakov](https://forum.ada-lang.io/u/dmitry-kazakov)
#### Post date: [September 23, 2026, 2:31pm UTC](https://forum.ada-lang.io/t/win32ada-inconsistent-results-with-time-data-of-files/4769/4 "2026-09-23T14:31:29Z")

</div>

> [@RobG9876](#):
>
> Note that the ada standard library gives me only the modification time (Ada.Directories.Modification\_Time). I want the accessed and creation times as well.

Because it is the greatest common denominator.

All depends on the file system at hand. NTFS, ext4, zfs have the creation time. As for the access time it is very unreliable, e.g. you can have none whatsoever, or turned off for performance reasons.

> [@RobG9876](#):
>
> That leaves the question on which struct layout to use. For the C stat struct there are numerous disagreeing definitions. Is the info in the [MS Learn site](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/stat-functions?view=msvc-170) correct?

Do not use the CRT layer (as we all know, Windows was not written in C, Basic it was 😀). Use the native API:

> **[BY\_HANDLE\_FILE\_INFORMATION (fileapi.h) - Win32 apps](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/ns-fileapi-by_handle_file_information)**
>
> Contains information that the GetFileInformationByHandle function retrieves.

This is what a Windows file system driver would report back on request.

---

<div class="post-metadata">

### Author: ![RobG9876](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/robg9876/32/663_2.png) [@RobG9876](https://forum.ada-lang.io/u/RobG9876)
#### Post date: [September 23, 2026, 3:08pm UTC](https://forum.ada-lang.io/t/win32ada-inconsistent-results-with-time-data-of-files/4769/5 "2026-09-23T15:08:37Z")

</div>

Thanks. Give me 3 weeks to test it, Away for a belated holiday

---

<div class="post-metadata">

### Author: ![RobG9876](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/robg9876/32/663_2.png) [@RobG9876](https://forum.ada-lang.io/u/RobG9876)
#### Post date: [October 12, 2026, 8:30am UTC](https://forum.ada-lang.io/t/win32ada-inconsistent-results-with-time-data-of-files/4769/6 "2026-10-12T08:30:42Z")

</div>

Works like a charm. Thanks

---

<div class="post-metadata">

### Author: ![system](https://forum.ada-lang.io/uploads/default/original/1X/e625e7957e269cbf6d3128dab48a9e54fe3a9bdc.png) [@system](https://forum.ada-lang.io/u/system)
#### Post date: [October 14, 2026, 8:31am UTC](https://forum.ada-lang.io/t/win32ada-inconsistent-results-with-time-data-of-files/4769/7 "2026-10-14T08:31:41Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
