Phil,

Excellent info, thank you and please pardon the top post.

Steve

On 1/26/11 5:18 PM, Philip Ross wrote:
Hi Steve,

On 26 January 2011 20:45, steve fox<[email protected]>  wrote:
I love this module, though some of the codes don't seem to be working e.g,
'Brazil/East' and 'Asia/Calcutta':

rio= TZInfo::Country.get('Brazil/East')
TZInfo::InvalidCountryCode: Invalid identifier
Brazil/East is a timezone identifier, not a country code. You need to
use it with TZInfo::Timezone.get instead of TZInfo::Country.get:

rio = TZInfo::Timezone.get('Brazil/East')
=>  #<TZInfo::LinkedTimezone: Brazil/East>

TZInfo::Country can be used to obtain the timezones for a particular
country (by its ISO 3166 two letter country code). For example, the
following code returns the timezones identifiers for Brazil:

TZInfo::Country.get('BR').zone_identifiers
=>  ["America/Noronha", "America/Belem", "America/Fortaleza",
"America/Recife", "America/Araguaina", "America/Maceio",
"America/Bahia", "America/Sao_Paulo", "America/Campo_Grande",
"America/Cuiaba", "America/Santarem", "America/Porto_Velho",
"America/Boa_Vista", "America/Manaus", "America/Eirunepe",
"America/Rio_Branco"]

Note that this doesn't include Brazil/East. This is because
Brazil/East is an alias for America/Sao_Paulo, provided for backwards
compatibility.

I got the country code information from /usr/shared/zoneinfo.  Should I be
referencing something else?
TZInfo doesn't actually use the system /usr/shared/zoneinfo directory.
The zoneinfo directory and TZInfo do both use the the tz database
(http://www.twinsun.com/tz/tz-link.htm) as their source though. You
can get a list of the identifiers of all the timezone included with
TZInfo using the TZInfo::Timezone.all_identifiers method.

The tz database zone.tab file
(http://tzinfo.rubyforge.org/svn/branches/0.3/data/zone.tab) lists all
the timezones associated with countries. You can access the zone.tab
data through the TZInfo API using the TZInfo::Country#zone_info
method. Please refer to the API documentation
(http://tzinfo.rubyforge.org/doc/) for details.

Kind regards,

Phil
_______________________________________________
TZInfo-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/tzinfo-users

_______________________________________________
TZInfo-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/tzinfo-users

Reply via email to