# timeZoneSelect

## Purpose

Helper tag for creating HTML selects for selecting from a list of time zones

## Examples

    // create a currency select
    <g:timeZoneSelect name="myTimeZone" value="${tz}" />

## Description

Attributes

- `name` (required) - The name of the select
- `value` (optional) - An instance of java.util.TimeZone. Defaults to the time zone for the current Locale if not specified

## Source

Show Source

    def timeZoneSelect = {attrs ->
            attrs['from'] = TimeZone.getAvailableIDs();
            attrs['value'] = (attrs['value'] ? attrs['value'].ID : TimeZone.getDefault().ID)
            def date = new Date()        // set the option value as a closure that formats the TimeZone for display
            attrs['optionValue'] = {
                TimeZone tz = TimeZone.getTimeZone(it);
                def shortName = tz.getDisplayName(tz.inDaylightTime(date), TimeZone.SHORT);
                def longName = tz.getDisplayName(tz.inDaylightTime(date), TimeZone.LONG);            def offset = tz.rawOffset;
                def hour = offset / (60 * 60 * 1000);
                def min = Math.abs(offset / (60 * 1000)) % 60;            return "${shortName}, ${longName} ${hour}:${min}"
            }        // use generic select
            out << select(attrs)
        }