Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"History is a tool used by politicians to justify their intentions." -- Ted Koppel


devel / comp.lang.ada / Re: Windows file timestamp converted to local time

SubjectAuthor
* Windows file timestamp converted to local timeMatt Borchers
`* Re: Windows file timestamp converted to local timeMatt Borchers
 +* Re: Windows file timestamp converted to local timeNiklas Holsti
 |+- Re: Windows file timestamp converted to local timeMatt Borchers
 |+- Re: Windows file timestamp converted to local timeRandy Brukardt
 |`* Re: Windows file timestamp converted to local timeMatt Borchers
 | `* Re: Windows file timestamp converted to local timeNiklas Holsti
 |  `- Re: Windows file timestamp converted to local timeSimon Wright
 +- Re: Windows file timestamp converted to local timeSimon Wright
 `- Re: Windows file timestamp converted to local timeDmitry A. Kazakov

1
Windows file timestamp converted to local time

<262bea8c-57ff-480e-b5aa-da94f0436e98n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10194&group=comp.lang.ada#10194

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:562f:b0:775:9026:3235 with SMTP id vv15-20020a05620a562f00b0077590263235mr496640qkn.2.1697473778117;
Mon, 16 Oct 2023 09:29:38 -0700 (PDT)
X-Received: by 2002:a05:6870:71cb:b0:1e9:dc1e:8384 with SMTP id
p11-20020a05687071cb00b001e9dc1e8384mr3684457oag.5.1697473777843; Mon, 16 Oct
2023 09:29:37 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Mon, 16 Oct 2023 09:29:37 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=209.104.249.61; posting-account=1tLBmgoAAAAfy5sC3GUezzrpVNronPA-
NNTP-Posting-Host: 209.104.249.61
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <262bea8c-57ff-480e-b5aa-da94f0436e98n@googlegroups.com>
Subject: Windows file timestamp converted to local time
From: mattborchers@gmail.com (Matt Borchers)
Injection-Date: Mon, 16 Oct 2023 16:29:38 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4895
 by: Matt Borchers - Mon, 16 Oct 2023 16:29 UTC

My need is to get the timestamp of a file corrected for local time. I am on Windows and the time should match the time that is reported on the Windows File Explorer which is is corrected for timezone and daylight savings time..

My program is a Win32 based program and the imported "localtime" C function does what is needed. However, sometimes the C function hangs after zero or more successful calls. I came to realize that this function is not thread-safe and so I wrote a wrapper function inside a protected object. This didn't help and I continued to add complexity to the protected code block but nothing seems to help. This is my current code:

type TM_STRUCT is record
tm_sec : INTEGER; --seconds after the minute - [0, 61]
tm_min : INTEGER; --minutes after the hour - [0, 59]
tm_hour : INTEGER; --hour since midnight - [0, 23]
tm_mday : INTEGER; --day of the month - [1, 31]
tm_mon : INTEGER; --months since January - [0, 11]
tm_year : INTEGER; --years since 1900
tm_wday : INTEGER; --days since Sunday - [0, 6]
tm_yday : INTEGER; --days since January 1 - [0, 365]
tm_isdst : INTEGER; --flag for alternate daylight savings time
end record;
pragma Convention( C, TM_STRUCT );

type A_TM_STRUCT is access all TM_STRUCT;

function LOCALTIME( timer : access OS_TIME ) return A_TM_STRUCT;
pragma Import( C, localtime, "localtime" );

protected type PROT_TIME is
entry LOCAL_TIME( ostime : GNAT.OS_Lib.OS_TIME; result : out TM_STRUCT );
private
busy : BOOLEAN := FALSE;
end PROT_TIME;

protected body PROT_TIME is

entry LOCAL_TIME( ostime : GNAT.OS_Lib.OS_TIME; result : out TM_STRUCT ) when not busy is
t : aliased GNAT.OS_Lib.OS_TIME := ostime;
begin
busy := TRUE;
result := localtime( t'Access ).all;
busy := FALSE;
end LOCAL_TIME;

end PROT_TIME;

pt : PROT_TIME;

function GET_LOCAL_TIME( ostime : GNAT.OS_Lib.OS_TIME ) return Ada.CALENDAR.TIME is
r : TM_STRUCT;
begin
pt.local_time( ostime, r );
return Ada.Calendar.time_of( ... );
end GET_LOCAL_TIME;

function GET_LAST_MODIFIED( path : STRING ) return Ada.CALENDAR.TIME is
(get_local_time( GNAT.OS_Lib.File_Time_Stamp( path ) ) );

My program calls "get_last_modified" with the file path.
The truth is that the behavior is the same without the guard condition. And the behavior is the same when written as a simple protected object, like:

protected PROT_TIME is
function LOCAL_TIME( ostime : GNAT.OS_Lib.OS_TIME ) return TM_STRUCT;
end PROT_TIME;

protected body PROT_TIME is

function LOCAL_TIME( ostime : GNAT.OS_Lib.OS_TIME ) return TM_STRUCT is
t : aliased GNAT.OS_Lib.OS_TIME := ostime;
begin
return localtime( t'Access ).all;
end LOCAL_TIME;

end PROT_TIME;

function GET_LOCAL_TIME( ostime : GNAT.OS_Lib.OS_TIME ) return Ada.CALENDAR.TIME is
r : TM_STRUCT;
begin
r := prot_time.local_time( ostime );
return Ada.Calendar.time_of( ... );
end GET_LOCAL_TIME;

The program seems to hang in the call to the "localtime" C function. A put_line immediately before the call to localtime will print.

Using the result in GNAT.OS_Lib.OS_TIME is correct and I could correct for the time zone myself, except for the fact that OS_TIME does not provide information about daylight savings time. Does anybody have any experience with dealing with file timestamps and converting them to the local time?

I hope I was both brief yet clear. Thank you.

Re: Windows file timestamp converted to local time

<df878937-795d-4c2d-ae75-e250361626a8n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10195&group=comp.lang.ada#10195

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:1a2a:b0:774:cd1:f036 with SMTP id bk42-20020a05620a1a2a00b007740cd1f036mr676818qkb.14.1697481328119;
Mon, 16 Oct 2023 11:35:28 -0700 (PDT)
X-Received: by 2002:a05:6808:19a2:b0:3ae:1e08:41e7 with SMTP id
bj34-20020a05680819a200b003ae1e0841e7mr36391oib.9.1697481327924; Mon, 16 Oct
2023 11:35:27 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Mon, 16 Oct 2023 11:35:27 -0700 (PDT)
In-Reply-To: <262bea8c-57ff-480e-b5aa-da94f0436e98n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=209.104.249.61; posting-account=1tLBmgoAAAAfy5sC3GUezzrpVNronPA-
NNTP-Posting-Host: 209.104.249.61
References: <262bea8c-57ff-480e-b5aa-da94f0436e98n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <df878937-795d-4c2d-ae75-e250361626a8n@googlegroups.com>
Subject: Re: Windows file timestamp converted to local time
From: mattborchers@gmail.com (Matt Borchers)
Injection-Date: Mon, 16 Oct 2023 18:35:28 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 9
 by: Matt Borchers - Mon, 16 Oct 2023 18:35 UTC

Below is the function from System.OS_Lib.
Does anybody know where the C implementation can be found?
Does anybody know where the C implementation of "localtime" is found?

function File_Time_Stamp (Name : C_File_Name) return OS_Time is
function File_Time (Name : Address) return OS_Time;
pragma Import (C, File_Time, "__gnat_file_time_name");
begin
return File_Time (Name);
end File_Time_Stamp;

Re: Windows file timestamp converted to local time

<kp5eucFogqpU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10196&group=comp.lang.ada#10196

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!nntp.comgw.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.holsti@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: Windows file timestamp converted to local time
Date: Mon, 16 Oct 2023 21:49:48 +0300
Organization: Tidorum Ltd
Lines: 22
Message-ID: <kp5eucFogqpU1@mid.individual.net>
References: <262bea8c-57ff-480e-b5aa-da94f0436e98n@googlegroups.com>
<df878937-795d-4c2d-ae75-e250361626a8n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net 4w6g4mc1465mtIOad99CiAGJZrGcPJt8HWQysP+VFxKFXiLYi7
Cancel-Lock: sha1:bvpwHaOZvrVqGLUH8hcd+/WpV7E= sha256:nVO1DfaoDy0Mm6hH2ybwUdSuUb3e8Z1Ix2JoYWRdYr8=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:102.0)
Gecko/20100101 Thunderbird/102.12.0
Content-Language: en-US
In-Reply-To: <df878937-795d-4c2d-ae75-e250361626a8n@googlegroups.com>
 by: Niklas Holsti - Mon, 16 Oct 2023 18:49 UTC

On 2023-10-16 21:35, Matt Borchers wrote:
> Below is the function from System.OS_Lib.
> Does anybody know where the C implementation can be found?
> Does anybody know where the C implementation of "localtime" is found?
>
> function File_Time_Stamp (Name : C_File_Name) return OS_Time is
> function File_Time (Name : Address) return OS_Time;
> pragma Import (C, File_Time, "__gnat_file_time_name");
> begin
> return File_Time (Name);
> end File_Time_Stamp;

(This question seems to be a follow-up ("Re:") to some earlier post, but
my newsreader does not seem to find or show that earlier post.)

What is the problem?

Have you tried using the standard Ada services:
Ada.Directories.Modification_Time and
Ada.Calendar.Time_Zones.Local_Time_Offset?

Re: Windows file timestamp converted to local time

<lyedhu4bxf.fsf@pushface.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10197&group=comp.lang.ada#10197

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: simon@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Windows file timestamp converted to local time
Date: Mon, 16 Oct 2023 20:14:36 +0100
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <lyedhu4bxf.fsf@pushface.org>
References: <262bea8c-57ff-480e-b5aa-da94f0436e98n@googlegroups.com>
<df878937-795d-4c2d-ae75-e250361626a8n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="3a79d3ca4da77f3d090f8710db067085";
logging-data="1714489"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Hjooj9c08P1DkNzIlmYsrDXigC2t1Aw8="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin)
Cancel-Lock: sha1:NXprGFFu8sQFo867geb40OBo2mw=
sha1:ToyBQZmAz0UAE1udpXzYBh1fZ0w=
 by: Simon Wright - Mon, 16 Oct 2023 19:14 UTC

Matt Borchers <mattborchers@gmail.com> writes:

> Below is the function from System.OS_Lib.
> Does anybody know where the C implementation can be found?
> Does anybody know where the C implementation of "localtime" is found?
>
> function File_Time_Stamp (Name : C_File_Name) return OS_Time is
> function File_Time (Name : Address) return OS_Time;
> pragma Import (C, File_Time, "__gnat_file_time_name");
> begin
> return File_Time (Name);
> end File_Time_Stamp;

For the first question, very likely to be in gcc/ada/adaint.c in the GCC
sources (https://github.com/gcc-mirror/gcc)

localtime() is in libc; depends on your OS.

Re: Windows file timestamp converted to local time

<3cee55f4-6804-4869-8f3e-3bff45ce4927n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10198&group=comp.lang.ada#10198

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ae9:ea18:0:b0:774:2308:eee7 with SMTP id f24-20020ae9ea18000000b007742308eee7mr2258qkg.0.1697484385663;
Mon, 16 Oct 2023 12:26:25 -0700 (PDT)
X-Received: by 2002:a05:6830:244d:b0:6bc:c93b:3066 with SMTP id
x13-20020a056830244d00b006bcc93b3066mr40396otr.1.1697484385487; Mon, 16 Oct
2023 12:26:25 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Mon, 16 Oct 2023 12:26:25 -0700 (PDT)
In-Reply-To: <kp5eucFogqpU1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=209.104.249.61; posting-account=1tLBmgoAAAAfy5sC3GUezzrpVNronPA-
NNTP-Posting-Host: 209.104.249.61
References: <262bea8c-57ff-480e-b5aa-da94f0436e98n@googlegroups.com>
<df878937-795d-4c2d-ae75-e250361626a8n@googlegroups.com> <kp5eucFogqpU1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3cee55f4-6804-4869-8f3e-3bff45ce4927n@googlegroups.com>
Subject: Re: Windows file timestamp converted to local time
From: mattborchers@gmail.com (Matt Borchers)
Injection-Date: Mon, 16 Oct 2023 19:26:25 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 5697
 by: Matt Borchers - Mon, 16 Oct 2023 19:26 UTC

On Monday, October 16, 2023 at 2:49:52 PM UTC-4, Niklas Holsti wrote:
> On 2023-10-16 21:35, Matt Borchers wrote:
> > Below is the function from System.OS_Lib.
> > Does anybody know where the C implementation can be found?
> > Does anybody know where the C implementation of "localtime" is found?
> >
> > function File_Time_Stamp (Name : C_File_Name) return OS_Time is
> > function File_Time (Name : Address) return OS_Time;
> > pragma Import (C, File_Time, "__gnat_file_time_name");
> > begin
> > return File_Time (Name);
> > end File_Time_Stamp;
> (This question seems to be a follow-up ("Re:") to some earlier post, but
> my newsreader does not seem to find or show that earlier post.)
>
> What is the problem?
>
> Have you tried using the standard Ada services:
> Ada.Directories.Modification_Time and
> Ada.Calendar.Time_Zones.Local_Time_Offset?

HERE IS MY ORIGINAL POST IF IT DIDN'T MAKE IT...

My need is to get the timestamp of a file corrected for local time. I am on Windows and the time should match the time that is reported on the Windows File Explorer which is is corrected for timezone and daylight savings time..

My program is a Win32 based program and the imported "localtime" C function does what is needed. However, sometimes the C function hangs after zero or more successful calls. I came to realize that this function is not thread-safe and so I wrote a wrapper function inside a protected object. This didn't help and I continued to add complexity to the protected code block but nothing seems to help. This is my current code:

type TM_STRUCT is record
tm_sec : INTEGER; --seconds after the minute - [0, 61]
tm_min : INTEGER; --minutes after the hour - [0, 59]
tm_hour : INTEGER; --hour since midnight - [0, 23]
tm_mday : INTEGER; --day of the month - [1, 31]
tm_mon : INTEGER; --months since January - [0, 11]
tm_year : INTEGER; --years since 1900
tm_wday : INTEGER; --days since Sunday - [0, 6]
tm_yday : INTEGER; --days since January 1 - [0, 365]
tm_isdst : INTEGER; --flag for alternate daylight savings time
end record;
pragma Convention( C, TM_STRUCT );

type A_TM_STRUCT is access all TM_STRUCT;

function LOCALTIME( timer : access OS_TIME ) return A_TM_STRUCT;
pragma Import( C, localtime, "localtime" );

protected type PROT_TIME is
entry LOCAL_TIME( ostime : GNAT.OS_Lib.OS_TIME; result : out TM_STRUCT );
private
busy : BOOLEAN := FALSE;
end PROT_TIME;

protected body PROT_TIME is

entry LOCAL_TIME( ostime : GNAT.OS_Lib.OS_TIME; result : out TM_STRUCT ) when not busy is
t : aliased GNAT.OS_Lib.OS_TIME := ostime;
begin
busy := TRUE;
result := localtime( t'Access ).all;
busy := FALSE;
end LOCAL_TIME;

end PROT_TIME;

pt : PROT_TIME;

function GET_LOCAL_TIME( ostime : GNAT.OS_Lib.OS_TIME ) return Ada.CALENDAR..TIME is
r : TM_STRUCT;
begin
pt.local_time( ostime, r );
return Ada.Calendar.time_of( ... );
end GET_LOCAL_TIME;

function GET_LAST_MODIFIED( path : STRING ) return Ada.CALENDAR.TIME is
(get_local_time( GNAT.OS_Lib.File_Time_Stamp( path ) ) );

My program calls "get_last_modified" with the file path.
The truth is that the behavior is the same without the guard condition. And the behavior is the same when written as a simple protected object, like:

protected PROT_TIME is
function LOCAL_TIME( ostime : GNAT.OS_Lib.OS_TIME ) return TM_STRUCT;
end PROT_TIME;

protected body PROT_TIME is

function LOCAL_TIME( ostime : GNAT.OS_Lib.OS_TIME ) return TM_STRUCT is
t : aliased GNAT.OS_Lib.OS_TIME := ostime;
begin
return localtime( t'Access ).all;
end LOCAL_TIME;

end PROT_TIME;

function GET_LOCAL_TIME( ostime : GNAT.OS_Lib.OS_TIME ) return Ada.CALENDAR..TIME is
r : TM_STRUCT;
begin
r := prot_time.local_time( ostime );
return Ada.Calendar.time_of( ... );
end GET_LOCAL_TIME;

The program seems to hang in the call to the "localtime" C function. A put_line immediately before the call to localtime will print.

Using the result in GNAT.OS_Lib.OS_TIME is correct and I could correct for the time zone myself, except for the fact that OS_TIME does not provide information about daylight savings time. Does anybody have any experience with dealing with file timestamps and converting them to the local time?

I hope I was both brief yet clear. Thank you.

Re: Windows file timestamp converted to local time

<ugks3g$2mvfi$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10199&group=comp.lang.ada#10199

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: randy@rrsoftware.com (Randy Brukardt)
Newsgroups: comp.lang.ada
Subject: Re: Windows file timestamp converted to local time
Date: Mon, 16 Oct 2023 21:39:09 -0500
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <ugks3g$2mvfi$1@dont-email.me>
References: <262bea8c-57ff-480e-b5aa-da94f0436e98n@googlegroups.com> <df878937-795d-4c2d-ae75-e250361626a8n@googlegroups.com> <kp5eucFogqpU1@mid.individual.net>
Injection-Date: Tue, 17 Oct 2023 02:38:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f60c9ad74c23009b0789f47cb2ded7c1";
logging-data="2850290"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oTDWAabrkEuozvX59vMDQXQjAP6ydzEI="
Cancel-Lock: sha1:TU/TxKHLEvvgHe4WPmbZwWv/hVc=
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246
X-RFC2646: Format=Flowed; Response
X-Priority: 3
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-MSMail-Priority: Normal
 by: Randy Brukardt - Tue, 17 Oct 2023 02:39 UTC

"Niklas Holsti" <niklas.holsti@tidorum.invalid> wrote in message
news:kp5eucFogqpU1@mid.individual.net...
> On 2023-10-16 21:35, Matt Borchers wrote:
>> Below is the function from System.OS_Lib.
>> Does anybody know where the C implementation can be found?
>> Does anybody know where the C implementation of "localtime" is found?
>>
>> function File_Time_Stamp (Name : C_File_Name) return OS_Time is
>> function File_Time (Name : Address) return OS_Time;
>> pragma Import (C, File_Time, "__gnat_file_time_name");
>> begin
>> return File_Time (Name);
>> end File_Time_Stamp;
>
>
> (This question seems to be a follow-up ("Re:") to some earlier post, but
> my newsreader does not seem to find or show that earlier post.)
>
> What is the problem?
>
> Have you tried using the standard Ada services:
> Ada.Directories.Modification_Time and
> Ada.Calendar.Time_Zones.Local_Time_Offset?

....as those will work on (almost) any target system, while the actual
implementation is going to be rather OS-dependent. And there never is a good
reason to use a GNAT-only (or any compiler-specific, for any compiler)
facility when there is an equivalent standard facility. Most of those
facilities pre-date the Ada ones.

Randy.

Re: Windows file timestamp converted to local time

<uglcse$2qs30$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10200&group=comp.lang.ada#10200

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Windows file timestamp converted to local time
Date: Tue, 17 Oct 2023 09:25:03 +0200
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <uglcse$2qs30$1@dont-email.me>
References: <262bea8c-57ff-480e-b5aa-da94f0436e98n@googlegroups.com>
<df878937-795d-4c2d-ae75-e250361626a8n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 17 Oct 2023 07:25:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f375846712243c1999d70938de18ff59";
logging-data="2977888"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/krGyvc7KExGtyWHmFONcM51u9CW/QHs8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:oEMQ8mb1Ef2OchB8QzFJMN8fbqo=
Content-Language: en-US
In-Reply-To: <df878937-795d-4c2d-ae75-e250361626a8n@googlegroups.com>
 by: Dmitry A. Kazakov - Tue, 17 Oct 2023 07:25 UTC

On 2023-10-16 20:35, Matt Borchers wrote:
> Below is the function from System.OS_Lib.
> Does anybody know where the C implementation can be found?
> Does anybody know where the C implementation of "localtime" is found?
>
> function File_Time_Stamp (Name : C_File_Name) return OS_Time is
> function File_Time (Name : Address) return OS_Time;
> pragma Import (C, File_Time, "__gnat_file_time_name");
> begin
> return File_Time (Name);
> end File_Time_Stamp;

If I correctly interpret the description, OS_Time is FILETIME under
Windows, i.e. 64-bit value.

https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime

As for implementation it likely calls to GetFileTime after obtaining a
handle to the file.

https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfiletime

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Windows file timestamp converted to local time

<04b87486-0614-4775-a40f-66138d08058an@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10202&group=comp.lang.ada#10202

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:6602:0:b0:412:8bb7:25a6 with SMTP id c2-20020ac86602000000b004128bb725a6mr44036qtp.4.1697551994523;
Tue, 17 Oct 2023 07:13:14 -0700 (PDT)
X-Received: by 2002:a05:6870:219c:b0:1e9:8db0:383 with SMTP id
l28-20020a056870219c00b001e98db00383mr979545oae.1.1697551994243; Tue, 17 Oct
2023 07:13:14 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Tue, 17 Oct 2023 07:13:13 -0700 (PDT)
In-Reply-To: <kp5eucFogqpU1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:188:ca01:c10:5590:bf9a:af40:f24d;
posting-account=1tLBmgoAAAAfy5sC3GUezzrpVNronPA-
NNTP-Posting-Host: 2601:188:ca01:c10:5590:bf9a:af40:f24d
References: <262bea8c-57ff-480e-b5aa-da94f0436e98n@googlegroups.com>
<df878937-795d-4c2d-ae75-e250361626a8n@googlegroups.com> <kp5eucFogqpU1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <04b87486-0614-4775-a40f-66138d08058an@googlegroups.com>
Subject: Re: Windows file timestamp converted to local time
From: mattborchers@gmail.com (Matt Borchers)
Injection-Date: Tue, 17 Oct 2023 14:13:14 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2700
 by: Matt Borchers - Tue, 17 Oct 2023 14:13 UTC

On Monday, October 16, 2023 at 2:49:52 PM UTC-4, Niklas Holsti wrote:
> On 2023-10-16 21:35, Matt Borchers wrote:
> > Below is the function from System.OS_Lib.
> > Does anybody know where the C implementation can be found?
> > Does anybody know where the C implementation of "localtime" is found?
> >
> > function File_Time_Stamp (Name : C_File_Name) return OS_Time is
> > function File_Time (Name : Address) return OS_Time;
> > pragma Import (C, File_Time, "__gnat_file_time_name");
> > begin
> > return File_Time (Name);
> > end File_Time_Stamp;
> (This question seems to be a follow-up ("Re:") to some earlier post, but
> my newsreader does not seem to find or show that earlier post.)
>
> What is the problem?
>
> Have you tried using the standard Ada services:
> Ada.Directories.Modification_Time and
> Ada.Calendar.Time_Zones.Local_Time_Offset?

Thank you for the suggestion of using "Ada.Directories.Modification_Time". I didn't think to look in that package. This function adjusts for daylight savings time and returns the time as displayed in Windows Explorer.

There needs to be better comments (and documentation) for these time related functions. It is often not clear what time is returned. It is safe to assume UTC or local time, but the daylight savings issue caused confusion.

Re: Windows file timestamp converted to local time

<kp7r1tF8sljU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10203&group=comp.lang.ada#10203

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.holsti@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: Windows file timestamp converted to local time
Date: Tue, 17 Oct 2023 19:28:45 +0300
Organization: Tidorum Ltd
Lines: 51
Message-ID: <kp7r1tF8sljU1@mid.individual.net>
References: <262bea8c-57ff-480e-b5aa-da94f0436e98n@googlegroups.com>
<df878937-795d-4c2d-ae75-e250361626a8n@googlegroups.com>
<kp5eucFogqpU1@mid.individual.net>
<04b87486-0614-4775-a40f-66138d08058an@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net +OnLft69gH2/FZ6SFNDU/Agz4swePK9p6YX1InxpTj3gshrfWp
Cancel-Lock: sha1:C6IhPhNhE+27+1vWVVVyNzOIen0= sha256:hM7q+nkDlIEyyGGE30foo7rEYQ1RnQ+83hP25KTpiFg=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:102.0)
Gecko/20100101 Thunderbird/102.12.0
Content-Language: en-US
In-Reply-To: <04b87486-0614-4775-a40f-66138d08058an@googlegroups.com>
 by: Niklas Holsti - Tue, 17 Oct 2023 16:28 UTC

On 2023-10-17 17:13, Matt Borchers wrote:
> On Monday, October 16, 2023 at 2:49:52 PM UTC-4, Niklas Holsti wrote:
>> On 2023-10-16 21:35, Matt Borchers wrote:
>>> Below is the function from System.OS_Lib.
>>> Does anybody know where the C implementation can be found?
>>> Does anybody know where the C implementation of "localtime" is found?
>>>
>>> function File_Time_Stamp (Name : C_File_Name) return OS_Time is
>>> function File_Time (Name : Address) return OS_Time;
>>> pragma Import (C, File_Time, "__gnat_file_time_name");
>>> begin
>>> return File_Time (Name);
>>> end File_Time_Stamp;
>> (This question seems to be a follow-up ("Re:") to some earlier post, but
>> my newsreader does not seem to find or show that earlier post.)
>>
>> What is the problem?
>>
>> Have you tried using the standard Ada services:
>> Ada.Directories.Modification_Time and
>> Ada.Calendar.Time_Zones.Local_Time_Offset?
>
> Thank you for the suggestion of using "Ada.Directories.Modification_Time".

Happy to help!

> I didn't think to look in that package.

Ada.Directories does, IMO, seem the best place for it, since it should
not depend on the type of the file -- text, sequential, etc.

> This function adjusts for daylight savings time and returns the time
> as displayed in Windows Explorer.
>
> There needs to be better comments (and documentation) for these time
> related functions. It is often not clear what time is returned.

Yes, but some of that documentation should not be in the Ada standard,
but in the compiler's documentation.

Ada.Directories.Modification_Time returns a value of type
Ada.Calendar.Time. However, "the time base associated with the type Time
of package Calendar is implementation defined" (RM 9.6(23)) so it should
be documented in the implementation documents, that is in the GNAT
documentation. Have you looked there?

Re: Windows file timestamp converted to local time

<lya5sh436m.fsf@pushface.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10204&group=comp.lang.ada#10204

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!nntp.comgw.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: simon@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Windows file timestamp converted to local time
Date: Tue, 17 Oct 2023 17:35:45 +0100
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <lya5sh436m.fsf@pushface.org>
References: <262bea8c-57ff-480e-b5aa-da94f0436e98n@googlegroups.com>
<df878937-795d-4c2d-ae75-e250361626a8n@googlegroups.com>
<kp5eucFogqpU1@mid.individual.net>
<04b87486-0614-4775-a40f-66138d08058an@googlegroups.com>
<kp7r1tF8sljU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="e4d906927758e7c1828bdb549aa2db9c";
logging-data="3229058"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX190gEaYlnHIvHf1eG0LdmLDTOIBzPP/6Es="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin)
Cancel-Lock: sha1:aFh9PUIHjqQYW28UiP/OY/gpxN8=
sha1:xPHlBREXZ70ye60NkE4E0FHlAJ8=
 by: Simon Wright - Tue, 17 Oct 2023 16:35 UTC

Niklas Holsti <niklas.holsti@tidorum.invalid> writes:

> Ada.Directories.Modification_Time returns a value of type
> Ada.Calendar.Time. However, "the time base associated with the type
> Time of package Calendar is implementation defined" (RM 9.6(23)) so it
> should be documented in the implementation documents, that is in the
> GNAT documentation. Have you looked there?

The GNAT RM says in Implementation Defined Characteristics[1]

"The time base used is that provided by the C library function gettimeofday."

[1] https://docs.adacore.com/live/wave/gnat_rm/html/gnat_rm/gnat_rm/implementation_defined_characteristics.html

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor