[
https://issues.apache.org/jira/browse/ASTERIXDB-1430?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15400850#comment-15400850
]
Vignesh Raghunathan commented on ASTERIXDB-1430:
------------------------------------------------
According to the documentation, time and datetime constructors convert the
given time to UTC. Furthermore, adjust-datetime-for-timezone and
adjust-time-for-timezone functions convert the given datetime/time values to
the timezone specified in the second argument and append the timezone in the
timezone field.
The given query could be written as
let $ct := current-datetime()
let $adjustedDatetime := adjust-datetime-for-timezone($ct, "-10:00")
let $nt := datetime($adjustedDatetime)
return {"ct": $ct, "adjustedDateTime": $adjustedDatetime, "nt":$nt}
which gives the result
{ "ct": datetime("2016-07-30T21:41:54.222Z"), "adjustedDateTime":
"2016-07-30T11:41:54.222-10:00", "nt": datetime("2016-07-30T21:41:54.222Z") }
"adjustedDateTime" holds the datetime value of "ct" converted to -10:00. "nt"
holds the value of "adjustedDateTime" converted back to UTC. This is the
expected behavior of the datetime constructor and adjust-datetime-for-timezone
functions.
> Unexpected behavior in datetime constructor
> -------------------------------------------
>
> Key: ASTERIXDB-1430
> URL: https://issues.apache.org/jira/browse/ASTERIXDB-1430
> Project: Apache AsterixDB
> Issue Type: Bug
> Components: Functions - AQL
> Reporter: Murtadha Hubail
> Labels: starter
>
> I used the function adjust-datetime-for-timezone(datetime, zone), which
> returns string type, to adjust the current datetime, then I wanted to use the
> returned value as datetime type.
> When I tried the following:
> {noformat}
> let $adjustedDatetime := adjust-datetime-for-timezone(current-datetime(),
> "-10:00")
> return datetime($adjustedDatetime)
> {noformat}
> The returned datetime value lost the adjustment.
> I think the datetime constructor should either respect the adjustment or
> throw an invalid format exception.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)