Weird? d = new date not current

Yes you have (or Norman answer).

Did you read my Post ?
Did you checked the system date in that computer ?
(Also: in the Desktop, cmd-n to create a new folder, then cmd-i and watch the creation and modification dates…)

Edit:
Ithink the 1904 year is replaced by a 1970 year in more recent Macintosh(es).

1904: Macs up to OS 9
1970: OS X and now macOS (as it is a UNIX derivative)

I sort of solved my problem, but I created a different one. I moved it to my PC and the problem still exists.
The problem restated.

fd as folderitem// (some location within a harddrive) dim orgDate as date Try orgDate = fd.creationdate //If fd does NOT exist, but has been declared, its date is 1904 and orgDate is now 1904 Catch err As NilObjectException OrgDate = New Date End Try
For some weird reason the try is now going to NOT Catch err but the wrong spot.
My new question is how do I get a Try within a Try. I am am in the meantime going to try an “If fd.exists” outside of my loop.

What do you really want to do ?

Is this related to your other (Xojo.Core.Date) question ?

Honestly, I am trying to get something that works.
They really are 2 independent questions.
For some reason suddenly things that have worked for years aren’t working.

It’s always possible you’ve found a bug. Go back to an older version of Xojo and see if it works as you expect.

The easiest/best way to do it is to create a very small sample project that you know works in the older version (verify that it works, naturally) and then try it in the newer version of Xojo. If it no longer works you have the perfect example project to attach to your Feedback report.

The nice thing about the small sample project is that once you remove all of the distraction of your much bigger project sometimes the real issue, and solution, become much more clear.

just try this code
make sure you do NOT have a file or directory on the desktop named “foobarsomethingelse”

Dim f As folderitem = specialfolder.desktop.child("foobarsomethingelse")

Dim d As New xojo.core.date(f.CreationDate.year, f.CreationDate.month, f.CreationDate.day, f.CreationDate.hour, f.CreationDate.Minute, f.CreationDate.Second, xojo.core.timezone.current)

since the folderitem DOESN"T exist its creation date is 0 - as in 0 seconds
this makes sense since something that doesnt exist HASN’T been created so how could it have a valid creation date

and DATES what are 0 seconds have a “base” date they start count forwards & backward from
and that date is in 1904 (Jan 1, 1904 at 00:00:00)

The code below (click in New Folder) return the correct date. So I do not know what your problem can be.

Dim f As FolderItem f = SelectFolder If f <> Nil Then MsgBox(f.Name + f.CreationDate.SQLDateTime) End If

BTW: some answers came while I wrote this.

This code comes from the LR (excepted the SQLDateTime part).

Xojo 2015r1
El Capitan .6

Also, your original code returns the correct date.

DID YOU CHECKED IF YOUR COMPUTER CLOCK IS SET TO 2017 OR 1904 ???

Yes Emile. The clocks are correct. Thank you. I hadn’t answered that.

Xojo version / OS Version ?

Current on everything

[quote=344689:@Eli Ott]1904: Macs up to OS 9
1970: OS X and now macOS (as it is a UNIX derivative)[/quote]
not true… it is 01-01-1904 … try it yourself if you don’t believe me

dim d as new date
d.TotalSeconds=0
msgbox d.SQLDate

why 1904? it is the 1st leap year of the 20th century

as to what I think your above issue is…

I would expect it to be 1904… you are looking at the CREATIONDATE, and the file has NOT BEEN CREATED
what you need to do it check

  • F.NIL is the path even valid
  • F.EXISTS does the file currently exist (in which case I would expect a recent/valid creation date)

I am not disputing that it should or should not be 1904 if a file doesn’t exist.
It took a while to realize that and I am sad.
I am confused because suddenly date is doing what it should have done for years. I also wonder what other surprises I’ll find when I change something else.
End of this discussion. I am miserably content.

The fact that it “date is doing what it should have done for years” means that you were doing something incorrectly, and now are doing it correctly… it is highly unlikely that it was Xojo , otherwise this forum would have lit up like a Christmas tree with many others posting similar complaints.

Realize there is a learning curve for this and anything else. Many of us have traversed that curve years ago, many others have just begun.

Thank you. I double checked on previous versions and it is back in 2009.
Thank you also for f.nil. I’ve always seen f = nil or f <>nil

yer both half right

  • yes macs up to macos 9 had a epoch date of 1904 and that macOS has a base epoch date the same as unix

  • but xojo’s epoch isn’t necessarily the same as the OS ones - it varies by framework ; old or new

http://developer.xojo.com/xojo-core-date
http://developer.xojo.com/date$TotalSeconds

[quote]//If fd does NOT exist, but has been declared, its date is 1904 and orgDate is now 1904
[/quote]

if it doesnt exist, why on earth do you care what the creation date is?

IF thefile.exists then // get the creation date else // no file so no need to get the date end if

Don’t select a non-existent file?
This problem is a bit like complaining that your car is the wrong color when you dont actually own a car. :slight_smile:
What would ‘something that works’ look like here?

Xojo should answer a Nil objection I think : You don’t have a car then don’t ask me its color. Because if Xojo answer me a color for my car, then I suppose I have a car (with this color).

Like in real life, if we don’t know the answer (or if we don’t understand the question) then just don’t answer, much better than a wrong answer.

But maybe I didn’t understand this topic and I gave a wrong answer :wink: .