A small enhancement request

29 views
Skip to first unread message

Chris Hermansen

unread,
Feb 11, 2016, 4:38:38 PM2/11/16
to Grails Dev Discuss
Good people;

I don't know if this is the correct place, or the correct way; please feel free to chastise me if not!

I propose adding a "timeZone" parameter to g:datePicker to permit the entry of date/time in user-local coordinates and conversion to server-local coordinates, and alternatively to force interpretation of time entered as in a specific timeZone (normally that of the server).

I propose showing the value selected as part of the datePicker fields.

Thanks!

Dustin Clark

unread,
Feb 11, 2016, 4:54:58 PM2/11/16
to grails-de...@googlegroups.com
Which version of Grails are you on?  I have a plugin that does almost exactly that, but I have not updated to Grails 3.x yet.


Dustin

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.
To post to this group, send email to grails-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/48882633-ccc3-4ffb-8893-781198bdcba0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

chris hermansen

unread,
Feb 11, 2016, 6:57:25 PM2/11/16
to grails-de...@googlegroups.com
Dustin, thanks for the reply.

I'm currently using 2.5.1

--
You received this message because you are subscribed to a topic in the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/grails-dev-discuss/l3VXl09CkDQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to grails-dev-disc...@googlegroups.com.

To post to this group, send email to grails-de...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Chris Hermansen · clhermansen "at" gmail "dot" com

C'est ma façon de parler.

Chris Malan

unread,
Feb 12, 2016, 4:16:55 AM2/12/16
to Grails Dev Discuss
I've had a look at this plugin, downloaded the code and looked at that.  This is really a neat plugin.  I've installed in in all my 2.5 projects for next time I upload.  Hope you port it to 3 soon.


On Friday, February 12, 2016 at 8:54:58 AM UTC+11, Dustin Clark wrote:
Which version of Grails are you on?  I have a plugin that does almost exactly that, but I have not updated to Grails 3.x yet.


Dustin

Sent from my iPhone

On Feb 11, 2016, at 3:38 PM, Chris Hermansen <clher...@gmail.com> wrote:

Good people;

I don't know if this is the correct place, or the correct way; please feel free to chastise me if not!

I propose adding a "timeZone" parameter to g:datePicker to permit the entry of date/time in user-local coordinates and conversion to server-local coordinates, and alternatively to force interpretation of time entered as in a specific timeZone (normally that of the server).

I propose showing the value selected as part of the datePicker fields.

Thanks!

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-discuss+unsub...@googlegroups.com.

Dustin Clark

unread,
Feb 12, 2016, 12:09:56 PM2/12/16
to grails-de...@googlegroups.com
Thanks Chris.  I have several plugins that I intend to upgrade, and this is one of them.  Will let you know when that happens.


Dustin

Sent from my iPhone

On Feb 12, 2016, at 3:16 AM, Chris Malan <antoni...@gmail.com> wrote:

I've had a look at this plugin, downloaded the code and looked at that.  This is really a neat plugin.  I've installed in in all my 2.5 projects for next time I upload.  Hope you port it to 3 soon.

On Friday, February 12, 2016 at 8:54:58 AM UTC+11, Dustin Clark wrote:
Which version of Grails are you on?  I have a plugin that does almost exactly that, but I have not updated to Grails 3.x yet.


Dustin

Sent from my iPhone

On Feb 11, 2016, at 3:38 PM, Chris Hermansen <clher...@gmail.com> wrote:

Good people;

I don't know if this is the correct place, or the correct way; please feel free to chastise me if not!

I propose adding a "timeZone" parameter to g:datePicker to permit the entry of date/time in user-local coordinates and conversion to server-local coordinates, and alternatively to force interpretation of time entered as in a specific timeZone (normally that of the server).

I propose showing the value selected as part of the datePicker fields.

Thanks!

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.

To post to this group, send email to grails-de...@googlegroups.com.

chris hermansen

unread,
Feb 12, 2016, 1:39:02 PM2/12/16
to grails-de...@googlegroups.com
Hi Dustin,

I read over the documentation and I'm not sure this does what I'm asking.

What I see is a disconnect between g:formatDate, for which the timezone CAN be specified via the timeZone parameter (and the setting verified when the "z" format code is included in the format string), and the g:datePicker, for which the timezone CANNOT be specified (nor verified).

According to my testing, the g:datePicker uses the server timezone, whereas the g:formatDate uses the client timezone unless changed by timeZone, which also seems weird to me... though for my current purposes, given that I can't configure g:datePicker to use the timezone of my choice, I'm grateful that it uses the server timezone.

On Thu, Feb 11, 2016 at 1:54 PM, Dustin Clark <dus...@captivatelabs.com> wrote:

--
You received this message because you are subscribed to a topic in the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/grails-dev-discuss/l3VXl09CkDQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to grails-dev-disc...@googlegroups.com.

To post to this group, send email to grails-de...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Dustin D. Clark

unread,
Feb 12, 2016, 3:11:10 PM2/12/16
to grails-de...@googlegroups.com
You shouldn’t specify the timezone parameter on either tag, as it will be detected for you.  Maybe I’m not following what you’re asking for, but the plugin basically does the following:

  • Detects user’s current timezone using this JS library
  • When dates are rendered (either in a datepicker or the formatDate tag), server time is adjusted to the user’s local time
  • When dates are posted back to your server, dates are adjusted from the user’s time back to server time.

As a practical example, say that server time is noon UTC, and I’m in central time (UTC -6).  Using formatDate on the current time (new Date()) would render 6AM.  Additionally, setting the value on a date picker to new Date() would render the date picker defaulted to 6AM.  However, when the form is submitted, the date is adjusted back to server time, so in your controller, you’d see noon again.

Anyways, hope this helps.

Dustin


chris hermansen

unread,
Feb 12, 2016, 4:26:00 PM2/12/16
to grails-de...@googlegroups.com
Thanks, Dustin, but that's not what I want.

I have a server that must run in a specific time zone (because that's where the events are that are being recorded).

I want all users everywhere to be working in that time zone conciously, because that's where the events are taking place.  So if they want to enter an event that's taking place at 15:20 in that locale, I want them to enter 15:20 in the data entry screen and I want them to see 15:20 on the report and I want them to be aware of the actual time zone at all times.  In other words, the users' time zone is irrelevant.

Make sense?


For more options, visit https://groups.google.com/d/optout.

Dustin D. Clark

unread,
Feb 12, 2016, 4:33:14 PM2/12/16
to grails-de...@googlegroups.com
Yes, it does, and there’s a much easier solution for that:

TimeZone.setDefault(TimeZone.getTimeZone("UTC"))

in Bootstrap.groovy And 

-Duser.timezone=UTC

on JAVA_OPTS.


Dustin

chris hermansen

unread,
Feb 12, 2016, 5:43:01 PM2/12/16
to grails-de...@googlegroups.com
Hi again, Dustin.

I've actually set my server's time zone in grails-app/conf/spring/resources.groovy, rather than using BootStrap.groovy and JAVA_OPTS.

But that doesn't deal withmy request, which is making g:datePicker timezone explicit and matching g:formatDate, if you see what I mean; g:datePicker needs a "timeZone" parameter. And it wouldn't hurt for the reference documentation to be explicit about the behaviours of both.  From what I can determine, g:datePicker lives on server time.  Not completely sure about g:formatDate.


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages