Xojo.Core.Date and creationDate

Is there an easy way of getting folderitem’s creationdate to a date declared as Xojo.Core.Date?
I’m asking because I want to apply Xojo.Core.Date.NOW to a file and the two aren’t compatible.

what have you tried ?

Dim dnOrg As Xojo.Core.Date fd as folderitem = IniHerd.IniFolder.Child("WordDictry.Txt") Try dnOrg = fd.CreationDate Catch err As NilObjectException dnOrg New Xojo.Core.Date End Try dnOrg = Xojo.core.Date.Now
The analyzer thinks “dnOrg = fd.CreationDate” is type mismatch and it expects Date but got Xojo.Core.Date

What I am doing with this method is that funky delete a file so I can save.
The analyzer also doesn’t like it when I apply “fd.CreationDate =dnOrg” to restore the date

right
fd.creation date IS a Date (from the classic framework) and dnOrg is a Xojo.Core.Date

while their contents both represent “dates” they are not the same type

its about like trying to say a can of oranges is an orange
both “contain” orange like stuff - but one is a can of oranges and the other an orange - not the same “type”

go read, http://developer.xojo.com/xojo-core-date
This is something I’d encourage you to do BEFORE asking a question here as then you might be able to suss this stuff out for yourself

That said note that a Xojo.Core.Date has numerous constructors (ways to create a new one)
The one of interest is

[code] Constructor(year As Integer, month As Integer, day As Integer, hour As Integer = 0, minute As Integer = 0, seconds As Integer = 0, nanoseconds As Integer = 0, timezone As TimeZone)

[code]
And the example is useful
Why ?
Well because a Date (see http://developer.xojo.com/date) has all those properties

The only thing missing is “TimeZone” which you can (according to the constructor for Xojo.Core.Date right above the one I pointed you to use Xojo.Core.TimeZone.Current

So you end up with

 Dim dnOrg As Xojo.Core.Date
  fd as folderitem = IniHerd.IniFolder.Child("WordDictry.Txt")
  dnOrg = new Xojo.Core.Date(fd.creation.year, fd.creation.month, fd.creation.day, fd.creation.hour, fd.creation.minute, fd.creation.second, Xojo.Core.TimeZone.Current)
  • or something really close to that -

Thank you.
I did read the example and pieced together some stuff.
So. To get the “times” from a folderitem to a variable, then they go then back,

Here are the lines I get the best least errors.

Dim dnOrg As Xojo.Core.Date Try dnOrg = Xojo.Core.Date(fd.CreationDate) //This is all it wanted Catch err As NilObjectException dnOrg As New Xojo.Core.Date //Error Cannot call something that is not a function End //Try is NOT allowed dnOrg = Xojo.core.Date.Now //This item does not exist

From the doc page for Xojo.Core.Date:

Convert a Classic Date to Xojo.Core.Date:

Dim d As New Date(2015, 10, 15) // Classic Date Dim xcd As New Xojo.Core.Date(d.Year, d.Month, d.Day, Xojo.Core.TimeZone.Current)

This example is shown for one of the Constructors, but I’ll add it to a more prominent Note at the beginning.

(This also looks almost exactly like what Norman replied with.)

dnOrg = New Xojo.Core.Date

Thanks but the analyzer doesn’t like it.
It says, “There is more than one item with this name and it’s not clear to which this refers.”

The documentation lists the constructors and their parameters. Tim was helping you with syntax.
http://developer.xojo.com/xojo-core-date

You can not create a new Xojo.Core.Date like this. Use one of its Constructors or just use Xojo.Core.Date.Now to get the current date.

My question restated is how do I get a core date to a folderitem. The analyzer doesn’t like the suggested codes.

Both Norman and I have posted code above that shows you how to convert a classic Date (from a FolderItem) to a Xojo.Core.Date.

I am sorrry I am obstinate, but I tried to show you what it wanted

I tried the suggested code and my analyzer rejects it. It says “Syntax Error” and that is all
I then get another error on the new. “Can’t call something that isn’t a function”

Dim dnOrg, dnMod As Xojo.Core.Date Try dnOrg = Xojo.Core.Date(fd.CreationDate.Year, fd.CreationDate.Month,, fd.CreationDate.Day, fd.CreationDate.Hour, fd.CreationDate.Minute) Catch err As NilObjectException dnOrg As New Xojo.Core.Date End dnOrg = Xojo.core.Date.Now

Dim dnOrg, dnMod As Xojo.Core.Date Try dnOrg = Xojo.Core.Date(fd.CreationDate.Year, fd.CreationDate.Month,, fd.CreationDate.Day, fd.CreationDate.Hour, fd.CreationDate.Minute) Catch err As NilObjectException dnOrg As New Xojo.Core.Date // <<<<<< REMOVE THIS !!!!! End dnOrg = Xojo.core.Date.Now

Thanks. No analyzer error

I would also remove or just move the last line ( dnOrg = Xojo.core.Date.Now). As it is, you are always going to read the current date and time!

Correction for Norm. i am still getting syntax error on dnOrg = Xojo.Core.Date(fd.CreationDate.Year, fd.CreationDate.Month,, fd.CreationDate.Day, fd.CreationDate.Hour, fd.CreationDate.Minute)

You need to use the Constructor (by using the New keyword) and supply the TimeZone:

dnOrg = New Xojo.Core.Date(fd.CreationDate.Year, fd.CreationDate.Month, fd.CreationDate.Day, fd.CreationDate.Hour, fd.CreationDate.Minute, Xojo.Core.TimeZone.Current)

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

of course you are

  1. too many commands after month
  2. you’re not using what I wrote which included the time zone

Dim dnOrg As Xojo.Core.Date fd as folderitem = IniHerd.IniFolder.Child("WordDictry.Txt") dnOrg = new Xojo.Core.Date(fd.creation.year, fd.creation.month, fd.creation.day, fd.creation.hour, fd.creation.minute, fd.creation.second, Xojo.Core.TimeZone.Current)