Skip to content

Commit

Permalink
Add timezone parameter to the plugin tags - fixes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
zoran119 committed Jul 13, 2014
1 parent ebe2248 commit 84274ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ You can pass configuration options to to date and time picker using `pickerOptio

Note that if an option is a string, pass it as string (note the `'\'`). Take care as none of the options are encoded!

You can also specify the timezone to be used when displaying a date:

<jqueryPicker:time name="startTime" value="${meetingInstance.startTime}" timeZone="${TimeZone.getTimeZone('GMT')}" />


Configuration
-------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ class JqueryDateTimePickerTagLib {
def name = attrs.remove('name')
def id = attrs.remove('id') ?: name
def pickerOptions = attrs.remove('pickerOptions') ?: [:]
def timeZone = attrs.remove('timeZone')
pickerOptions.dateFormat = grailsApplication.config.jqueryDateTimePicker.format.picker.date ?: "'dd/mm/yy'"
pickerOptions.timeFormat = grailsApplication.config.jqueryDateTimePicker.format.picker.time ?: "'HH:mm'"
out << render(template: '/popup', plugin: 'jqueryDateTimePicker', model: [function: function, value: value, valueFormat: valueFormat, name: name, id: id, pickerOptions: formatPickerOptions(pickerOptions), attrs: formatAttributes(attrs)])
out << render(template: '/popup', plugin: 'jqueryDateTimePicker', model: [function: function, value: value, valueFormat: valueFormat, name: name, id: id, pickerOptions: formatPickerOptions(pickerOptions), timeZone: timeZone, attrs: formatAttributes(attrs)])
}

private formatAttributes(attributeMap) {
Expand Down
2 changes: 1 addition & 1 deletion grails-app/views/_popup.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
${pickerOptions}
});
</g:javascript>
<input type="text" name="${name}" id="${id}" <g:if test="${value}">value="${formatDate(date:value, format:valueFormat)}"</g:if> ${attrs} />
<input type="text" name="${name}" id="${id}" <g:if test="${value}">value="${formatDate(date:value, format:valueFormat, timeZone:timeZone)}"</g:if> ${attrs} />

0 comments on commit 84274ee

Please sign in to comment.