Re: [R] RODBC & POSIX & Daylight Saving blues

2004-11-12 Thread Duncan Murdoch
On Fri, 12 Nov 2004 16:27:41 +, Bernie McConnell
<[EMAIL PROTECTED]> wrote :

>Many thanks for the responses about how to read datetimes into POSIXct 
>which refer to straight GMT times without regard to Daylight Saving.  To 
>reiterate, I''m using R 2.0.0 on win2000.
>
>I have tried Gabor's suggestion,see below, which did not work for me.  The 
>fundamental setting (for me) appears to be in the registry:
>
>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
>
>The values here are most readily altered using the 'Date/ TIme properties' 
>window (just double click the wee digital clock on the right of the window 
>task bar).  When I disable Daylight Saving a registry variable 
>called  DisableAutoDaylightTimeSet is created and is set to 1.  This can be 
>observed with regedit.  Now all works perfectly with my date handling.  So 
>it seems that setting the timezone to GMT is necessary but not sufficient 
>for my needs
>
>I confess that I do not understand the relationship between setting 
>registry variables and environment (eg TZ="GMT").
>
>In practice I would like to keep my win200 machine with Daylight Saving 
>enabled - for the sake of other applications.  One strategy is to make the 
>required registry alterations immediately before and after any R code which 
>handles dates.  But then I'm rather worried whether continuously enabling / 
>disabling Daylight Saving would have dire consequences for other 
>applications and the well-being of my already shaky OS.  Is this the right 
>route - and if so could someone please guide me how to achieve this in R 
>for win2000?
>
>Perhaps a better strategy would be to introduce some set-able option within 
>R that forced date handling to ignore Daylight Saving.  But here I have 
>insufficient expertise and can only appeal to the continuing generosity of 
>the developer community.
>
>I am sure that there are many R users in the same position as me - but 
>perhaps they don't all realize it!

I think you probably want to use as.is=TRUE when you retrieve the
results, then use the date conversion functions to specify the time
zone explicitly, e.g. asPOSIXct(x, tz='GMT'). 

Duncan Murdoch

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] RODBC & POSIX & Daylight Saving blues

2004-11-12 Thread Bernie McConnell
Many thanks for the responses about how to read datetimes into POSIXct 
which refer to straight GMT times without regard to Daylight Saving.  To 
reiterate, I''m using R 2.0.0 on win2000.

I have tried Gabor's suggestion,see below, which did not work for me.  The 
fundamental setting (for me) appears to be in the registry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
The values here are most readily altered using the 'Date/ TIme properties' 
window (just double click the wee digital clock on the right of the window 
task bar).  When I disable Daylight Saving a registry variable 
called  DisableAutoDaylightTimeSet is created and is set to 1.  This can be 
observed with regedit.  Now all works perfectly with my date handling.  So 
it seems that setting the timezone to GMT is necessary but not sufficient 
for my needs

I confess that I do not understand the relationship between setting 
registry variables and environment (eg TZ="GMT").

In practice I would like to keep my win200 machine with Daylight Saving 
enabled - for the sake of other applications.  One strategy is to make the 
required registry alterations immediately before and after any R code which 
handles dates.  But then I'm rather worried whether continuously enabling / 
disabling Daylight Saving would have dire consequences for other 
applications and the well-being of my already shaky OS.  Is this the right 
route - and if so could someone please guide me how to achieve this in R 
for win2000?

Perhaps a better strategy would be to introduce some set-able option within 
R that forced date handling to ignore Daylight Saving.  But here I have 
insufficient expertise and can only appeal to the continuing generosity of 
the developer community.

I am sure that there are many R users in the same position as me - but 
perhaps they don't all realize it!

Many thanks
Bernie McConnell
[EMAIL PROTECTED]
Sea Mammal Reserach Unit
University of St Andrews
--
Gabor Grothendieck  myway.com> writes:
:
: Prof Brian Ripley  stats.ox.ac.uk> writes:
:
: : If you set it to GMT for the duration of the sqlFetch call, it should do
: : as you intended (but had not told R, which is not clairvoyant).
: :
:
: On Windows you have to set the whole computer to GMT which has
Paul Roebuck pointed out to me offlist that this can be done
per process in Windows too so I was wrong on this point.
   ... start up Windows console ...
   cd \Program Files\rw2001beta
   set TZ=GMT
   bin\Rgui
In R,
   Sys.time() # displays date and time in GMT time zone
I also tried doing this from within R but was unsuccessful:
   R> Sys.time()
   [1] "2004-11-11 11:37:53 Eastern Standard Time"
   R> Sys.putenv(TZ = "GMT")
   R> Sys.time()  # wanted GMT result but did not get it
   [1] "2004-11-11 11:38:08 Eastern Standard Time"
   R> R.version.string  # Windows XP
   [1] "R version 2.0.1, 2004-11-04"
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] RODBC & POSIX & Daylight Saving blues

2004-11-11 Thread Gabor Grothendieck
Gabor Grothendieck  myway.com> writes:

: 
: Prof Brian Ripley  stats.ox.ac.uk> writes:
: 

: : If you set it to GMT for the duration of the sqlFetch call, it should do
: : as you intended (but had not told R, which is not clairvoyant).
: : 
: 
: On Windows you have to set the whole computer to GMT which has

Paul Roebuck pointed out to me offlist that this can be done
per process in Windows too so I was wrong on this point.

   ... start up Windows console ...
   cd \Program Files\rw2001beta
   set TZ=GMT
   bin\Rgui

In R,

   Sys.time() # displays date and time in GMT time zone


I also tried doing this from within R but was unsuccessful:

   R> Sys.time()
   [1] "2004-11-11 11:37:53 Eastern Standard Time"
   R> Sys.putenv(TZ = "GMT")
   R> Sys.time()  # wanted GMT result but did not get it
   [1] "2004-11-11 11:38:08 Eastern Standard Time"
   R> R.version.string  # Windows XP
   [1] "R version 2.0.1, 2004-11-04"

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] RODBC & POSIX & Daylight Saving blues

2004-11-11 Thread Gabor Grothendieck
Prof Brian Ripley  stats.ox.ac.uk> writes:

: 
: On Thu, 11 Nov 2004, Bernie McConnell wrote:
: 
: > Dear All,
: >
: > The recent improvement in RODBC to recognize datetimes in tables has
: > exposed my ongoing confusion.
: >
: > All my data are obtained from a satellite system (Argos) which tags events
: > in the GMT time zone.  Daylight saving is ignored.  To my way of thinking
: > this means that
: >
: >1.  twelve-o-clock means halfway through the day regardless of season, 
and
: >2.  the difftime of any two dates where the time is set to
: > twelve-o-clock should be an integer, regardless of which season each of the
: > dates are in.
: >
: > I illustrate my confusion with a two-line table in an Access 2000 database
: > table where the single field called 'theDate' contains the two values:
: >
: > 30/07/04 12:00:00
: > 30/11/04 12:00:00
: >
: > then I bring the datetimes into R with the following code:
: >
: >  > library (RODBC)
: >  > theChannel <- odbcConnect("phonetagcopy", "", "")
: >  > pp <- sqlFetch(theChannel, "DateTest")
: >  > odbcClose(theChannel)
: >  > pp$theDate
: > [1] "2004-07-30 12:00:00 GMT Daylight Time"
: > [2] "2004-11-30 12:00:00 GMT Standard Time"
: >  >
: >  > unclass(pp$theDate) / 86400
: > [1] 12629.46 12752.50
: > attr(,"tzone")
: > [1] ""
: >  >
: >  > difftime (pp$theDate[1], pp$theDate[2])
: > Time difference of -123.0417 days
: >
: > It appears that sqlFetch has (in this case wrongly) assumed that my
: > datetimes are corrected for Daylight Saving.  How can I persuade it to
: > accept that all my datetimes are in straight GMT?
: 
: All date-time conversions in R by default occurs in the current timezone.
: If you set it to GMT for the duration of the sqlFetch call, it should do
: as you intended (but had not told R, which is not clairvoyant).
: 

On Windows you have to set the whole computer to GMT which has
the potential to interfere with other programs so I don't think 
that that can be the final solution.  I believe that on UNIX it
would be better since its per process there but even then
it has the potential to disrupt the current R session.

If the data is stored in a table using a type that does not have
time zones then it should be mapped into a datetime class in R that 
also has no time zones.   It would be safer to convert it to chron
or to create some new datetime class that matches the data's type
or not convert it and leave it to the user.

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] RODBC & POSIX & Daylight Saving blues

2004-11-11 Thread Prof Brian Ripley
On Thu, 11 Nov 2004, Bernie McConnell wrote:

> Dear All,
>
> The recent improvement in RODBC to recognize datetimes in tables has
> exposed my ongoing confusion.
>
> All my data are obtained from a satellite system (Argos) which tags events
> in the GMT time zone.  Daylight saving is ignored.  To my way of thinking
> this means that
>
>1.  twelve-o-clock means halfway through the day regardless of season, and
>2.  the difftime of any two dates where the time is set to
> twelve-o-clock should be an integer, regardless of which season each of the
> dates are in.
>
> I illustrate my confusion with a two-line table in an Access 2000 database
> table where the single field called 'theDate' contains the two values:
>
> 30/07/04 12:00:00
> 30/11/04 12:00:00
>
> then I bring the datetimes into R with the following code:
>
>  > library (RODBC)
>  > theChannel <- odbcConnect("phonetagcopy", "", "")
>  > pp <- sqlFetch(theChannel, "DateTest")
>  > odbcClose(theChannel)
>  > pp$theDate
> [1] "2004-07-30 12:00:00 GMT Daylight Time"
> [2] "2004-11-30 12:00:00 GMT Standard Time"
>  >
>  > unclass(pp$theDate) / 86400
> [1] 12629.46 12752.50
> attr(,"tzone")
> [1] ""
>  >
>  > difftime (pp$theDate[1], pp$theDate[2])
> Time difference of -123.0417 days
>
> It appears that sqlFetch has (in this case wrongly) assumed that my
> datetimes are corrected for Daylight Saving.  How can I persuade it to
> accept that all my datetimes are in straight GMT?

All date-time conversions in R by default occurs in the current timezone.
If you set it to GMT for the duration of the sqlFetch call, it should do
as you intended (but had not told R, which is not clairvoyant).

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] RODBC & POSIX & Daylight Saving blues

2004-11-11 Thread Bernie McConnell
Dear All,
The recent improvement in RODBC to recognize datetimes in tables has 
exposed my ongoing confusion.

All my data are obtained from a satellite system (Argos) which tags events 
in the GMT time zone.  Daylight saving is ignored.  To my way of thinking 
this means that

  1.  twelve-o-clock means halfway through the day regardless of season, and
  2.  the difftime of any two dates where the time is set to 
twelve-o-clock should be an integer, regardless of which season each of the 
dates are in.

I illustrate my confusion with a two-line table in an Access 2000 database 
table where the single field called 'theDate' contains the two values:

30/07/04 12:00:00
30/11/04 12:00:00
then I bring the datetimes into R with the following code:
> library (RODBC)
> theChannel <- odbcConnect("phonetagcopy", "", "")
> pp <- sqlFetch(theChannel, "DateTest")
> odbcClose(theChannel)
> pp$theDate
[1] "2004-07-30 12:00:00 GMT Daylight Time"
[2] "2004-11-30 12:00:00 GMT Standard Time"
>
> unclass(pp$theDate) / 86400
[1] 12629.46 12752.50
attr(,"tzone")
[1] ""
>
> difftime (pp$theDate[1], pp$theDate[2])
Time difference of -123.0417 days
It appears that sqlFetch has (in this case wrongly) assumed that my 
datetimes are corrected for Daylight Saving.  How can I persuade it to 
accept that all my datetimes are in straight GMT?

OS:Win2000
R 2.0.0
RODBC version 1.1-2
Sys.getlocale()
[1] "LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United 
Kingdom.1252;LC_MONETARY=C;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252"
>

Many thanks
Bernie McConnell
Sea Mammal Research Unit
University of St Andrews
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html