I think I have found my problem. I post this here in case it helps anyone else. The java date constructor is initialized with a long, my attempts use a literal are what caused it to fail. I cast my literal as a long xs:long("133554732") and it worked, though not perfectly because epoch is in seconds and java is milliseconds. Thus I had to multiply my literal by 1000 first and then cast it as a long let $fdate: =133554732*1000 let $edat := dt:new(xs:long($fdate)) I then can access the TimeZone.IsDaylightTime property
Thanks to Christian for his help on this. Randy
On Wed, Dec 12, 2012 at 1:13 AM, Randy reed randywreed@gmail.com wrote:
Hi Christian,
Thanks for your response. I think that fn:implicit-timezone() would work for current dates but I'm not sure if it would work for dates in the past since it doesn't take any arguements.
I need some way that it can take a date in utc and adjust to the current timezone if its during that time period (i.e. we are currently in standard time) or adjust it if it was in the past during daylight savings time. If there was something that could read a utc date and then indicate whether it was during the daylight savings time period or not I could make the time adjustment.
In java there is a inDaylightTime property but it requires a date and timezone object. and it errors when I try to invoke it "invalid arguments" when it tries to initialize the constructor..
declare namespace tz = "java:java.util.TimeZone"; declare namespace dt = "java:java.util.Date";
let $fdate := dt:new(1347425558) let $tmz := tz:getDefault() let $day := tz:inDaylightTime($tmz, $fdate) return $day
Any help you could provide would be much appreciated. I am not a Java programmer so I might not understand something here.
Randy
On Dec 11, 2012 6:18 PM, "Christian GrĂ¼n" christian.gruen@gmail.com wrote:
Hi Randy,
fn:implicit-timezone() may come in handy here. It returns your current local timezone:
http://www.xqueryfunctions.com/xq/fn_implicit-timezone.html
Best, Christian ___________________________
On Wed, Dec 12, 2012 at 12:13 AM, Randy reed randywreed@gmail.com wrote:
Hi All,
I wrote a xquery in Basex that created an xml file that calculated student grades. Points are dependent on students doing an activity in a window which ends at midnight on sunday each week. The date/time of the activities are stored in the source file in UTC. However, to know if they met the deadline, I need it in local time. I do this by creating a function that translates epoch to a regulate dateTime variable. But I see that when we left daylight savings time, things were thrown off by an hour. The command I use is:
adjust-dateTime-to-timezone((xs:dateTime("1970-01-01T00:00:00-00:00")
- xs:dayTimeDuration(concat("PT", $v,
"S"))),xs:dayTimeDuration('-PT4H'))
clearly the problem is the last part -PT4H, because dates that fall after the switch back to standard time from daylight savings time should be -PT5H. Is there a better way of doing this? Is there another command that will give me a localized date that takes into account daylight savings time issues? I tried to set a java calendar but I could not make it work.
Any help would be gratefully appreciated. Thanks in advance Randy
-- Dr. Randall Reed Assistant Professor, Dept. of Philosophy and Religion Appalachian State University _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
basex-talk@mailman.uni-konstanz.de