What's up with File.ctime?

Hello,
I need to notate the date/time attributes of files. I’m using File.ctime
and trimming it back to show just day, date, and time.

filetime = File.ctime(txtfile)
filetime = filetime.to_s.gsub!(/ -.*$/, “”)

But, I’ve noticed that files that list in the directories as being dated
November 8 are showing via ctime as November 13 files. What’s up?

Thanks,
Peter

On 11/14/06, Peter B. [email protected] wrote:

Hello,
I need to notate the date/time attributes of files. I’m using File.ctime
and trimming it back to show just day, date, and time.

filetime = File.ctime(txtfile)
filetime = filetime.to_s.gsub!(/ -.*$/, “”)

But, I’ve noticed that files that list in the directories as being dated
November 8 are showing via ctime as November 13 files. What’s up?

Perhaps dir/ls shows mtime? Try checking mtime/ctime/atime to see
which is the right one.
To display ctime on windows, try dir /T:C on unix ls -l --time=ctime

Jan S. wrote:

On 11/14/06, Peter B. [email protected] wrote:

Hello,
I need to notate the date/time attributes of files. I’m using File.ctime
and trimming it back to show just day, date, and time.

filetime = File.ctime(txtfile)
filetime = filetime.to_s.gsub!(/ -.*$/, “”)

But, I’ve noticed that files that list in the directories as being dated
November 8 are showing via ctime as November 13 files. What’s up?

Perhaps dir/ls shows mtime? Try checking mtime/ctime/atime to see
which is the right one.
To display ctime on windows, try dir /T:C on unix ls -l --time=ctime

Thanks, Jan. Actually, I figured it out for myself. Looking deeper into
it, I found File.stat.mtime, and that’s I’m using now, and it works.
.ctime, I guess, stands for “change time,” so, it doesn’t actually state
the timestamp of the file as it is. Thanks again.

On 11/14/06, Peter B. [email protected] wrote:

November 8 are showing via ctime as November 13 files. What’s up?

Perhaps dir/ls shows mtime? Try checking mtime/ctime/atime to see
which is the right one.
To display ctime on windows, try dir /T:C on unix ls -l --time=ctime

Thanks, Jan. Actually, I figured it out for myself. Looking deeper into
it, I found File.stat.mtime, and that’s I’m using now, and it works.
.ctime, I guess, stands for “change time,” so, it doesn’t actually state
the timestamp of the file as it is. Thanks again.

Well, I thought ctime = creation time :wink: Now I’ve learned something as
well.

On Nov 14, 2006, at 9:50 AM, Jan S. wrote:

On 11/14/06, Peter B. [email protected] wrote:

Thanks, Jan. Actually, I figured it out for myself. Looking deeper
into
it, I found File.stat.mtime, and that’s I’m using now, and it works.
.ctime, I guess, stands for “change time,” so, it doesn’t actually
state
the timestamp of the file as it is. Thanks again.

Well, I thought ctime = creation time :wink: Now I’ve learned
something as well.

Just to make things a little clearer:

the ‘change’ referenced by ‘ctime’ is a change to the inode (or
metadata) for the file. So for example if the ownership or
permissions of a file change then ctime will be updated. If the
length of a file is changed (i.e. data is appended to the file) then
ctime will change. The mtime field on the other hand only changes
when data is written to the file (either new data appended to the end
or existing data is modified).

Lots of people think ctime = ‘creation time’ but the Posix API
doesn’t actually provide access to a ‘create time’.

I believe some Windows and Mac OS filesystems do have a notion of
‘create time’ that is recorded separately from the Posix ‘ctime’. I
don’t know what the APIs are
to access that timestamp on those platforms.

Gary W.

Hugh S. wrote:

On Tue, 14 Nov 2006, Jan S. wrote:

On 11/14/06, Peter B. [email protected] wrote:

Hello,
I need to notate the date/time attributes of files. I’m using File.ctime
and trimming it back to show just day, date, and time.
[…]
But, I’ve noticed that files that list in the directories as being dated
November 8 are showing via ctime as November 13 files. What’s up?

Perhaps dir/ls shows mtime? Try checking mtime/ctime/atime to see
which is the right one.
To display ctime on windows, try dir /T:C on unix ls -l --time=ctime

ls -lu ;# => atime
ls -lc ;# => ctime
ls -l ;# => mtime

ctime means Inode modified, i.e. created, chmod’ed, etc. See man ls
if you’re on unix. DIR /T:A gives access time according to XP docs.

    Hugh

Thanks, you guys. Nope, I’m on Windows. Yes, “dir /t:a” is probably the
equivalent to ctime, but, again, that’s not what I want. I just want the
file time as it’s listed in a garden-variety “dir.”

On Tue, 14 Nov 2006, Jan S. wrote:

On 11/14/06, Peter B. [email protected] wrote:

Hello,
I need to notate the date/time attributes of files. I’m using File.ctime
and trimming it back to show just day, date, and time.
[…]
But, I’ve noticed that files that list in the directories as being dated
November 8 are showing via ctime as November 13 files. What’s up?

Perhaps dir/ls shows mtime? Try checking mtime/ctime/atime to see
which is the right one.
To display ctime on windows, try dir /T:C on unix ls -l --time=ctime

ls -lu ;# => atime
ls -lc ;# => ctime
ls -l ;# => mtime

ctime means Inode modified, i.e. created, chmod’ed, etc. See man ls
if you’re on unix. DIR /T:A gives access time according to XP docs.

    Hugh