[squeak-dev] DirectoryEntryFile>>modificationTime (etc) UTC handling broken

tim Rowledge tim at rowledge.org
Mon Nov 9 01:27:04 UTC 2020



> On 2020-11-08, at 4:57 PM, David T. Lewis <lewis at mail.msen.com> wrote:
> 
> On Sun, Nov 08, 2020 at 10:58:13AM -0800, tim Rowledge wrote:
>> Something has broken wrt the handling of the DirectoryEntryFile conversion of the file times.
> 
[snip]
>> I'd guess that there ought to be a DateAndTime class>fromLocalSeconds: or similar? Timezones hurt my head so I'm very keen to pass the buck to people with a more direct interest in the chronology stuff. The #creationDateAndTime obviously needs the same solution.
>> 
> 
> I think you're on the right track here, although I don't think
> we would want to add this directly to DateAndTime. As Chris would
> probably point out, the API is messy enough already.
> 
> But somebody has figured out how to make this mess behave reasonably
> in the FileList, so it must be fixable.

The FileList simply uses the no-idea-about-TZ code and happened to get it right by accident ;-)

There is actually a fairly simple, though tacky solution.


!DirectoryEntry methodsFor: 'access' stamp: 'tpr 11/8/2020 17:18'!
modificationDateAndTime
	"The DateAndTime my entry in the file system was last modified."
	^ DateAndTime fromSeconds: modificationTime - DateAndTime localOffsetSeconds! !

Obviously required for creationTimeAndDate too.

An alternative that would approach from the creation end would be to subtract the localOffsetSeconds in the DirectoryEntry>>#setDirectory:name:creationTime:modificationTime:fileSize: method - but then we'd also have to fix the FileList and all the other senders of #modificationTime & #creationTime to use DateAndTime. Not that we  shouldn't fix those - looking at some of them  I suspect some interesting bugs might have been caused by the errant TZ factor.

tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Useful random insult:- He fell out of the ugly tree and hit every branch on the way down.




More information about the Squeak-dev mailing list