Thanks David, now I wonder how you can have as.Date() render the date using
local time rather than UTC.

Andrew

On Mon, Sep 13, 2010 at 12:08 PM, David Winsemius <dwinsem...@comcast.net>wrote:

>
> On Sep 13, 2010, at 11:56 AM, Andrew Yee wrote:
>
>  I'm trying to understand why as.Date() is converting a the modified date
>> of
>> a file from August 22 to August 23.
>>
>>  foo <- file.info(file.to.process)
>>> str(foo)
>>>
>> 'data.frame':   1 obs. of  10 variables:
>> $ size  : num 5.37e+09
>> $ isdir : logi FALSE
>> $ mode  :Class 'octmode'  int 436
>> $ mtime : POSIXct, format: "2010-08-22 23:14:52"
>> $ ctime : POSIXct, format: "2010-09-13 11:34:31"
>> $ atime : POSIXct, format: "2010-09-09 15:42:00"
>> $ uid   : int 503
>> $ gid   : int 503
>> $ uname : chr "ayee"
>> $ grname: chr "ayee"
>>
>>  as.Date(foo$mtime)
>>>
>> [1] "2010-08-23"
>>
>> In this case as.Date(foo$mtime) gives August 23.  I would have expected
>> August 22.
>>
>
> You are pretty close to midnight. Probably a TZ issue. Check your locale
> settings versus UTC/GMT.
>
> >  dt <- as.POSIXct("2010-08-22 23:14:52")
> > as.Date(dt)
> [1] "2010-08-23"
>
> Happens to me too, but when its 23:14 here, (US-EDT) it's the next day in
> Greenwich. The help page says:
> "The last [POSIXct] is converted to days by ignoring the time after
> midnight in the representation of the time in UTC." That is not entirely
> clear to my reading, but I am forced to conclude that it means as.Date
> returns the Date in UTC terms rather than in local terms.
>
> --
> David.
>
>
>> Thanks,
>> Andrew
>>
>>  sessionInfo()
>>>
>> R version 2.11.1 Patched (2010-09-11 r52901)
>> Platform: x86_64-unknown-linux-gnu (64-bit)
>>
>> locale:
>> [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>> [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>> [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
>> [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
>> [9] LC_ADDRESS=C               LC_TELEPHONE=C
>> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> David Winsemius, MD
> West Hartford, CT
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to