[haiku-commits] Re: r37718 - in haiku/trunk: headers/os/locale src/kits/locale

  • From: Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 23 Jul 2010 17:29:48 +0200

On 2010-07-23 at 15:19:33 [+0200], pulkomandy@xxxxxxxxxxxxxxxxx wrote:
[ ... ]
> +void
> +BTimeZone::Name(BString& name)
> +{
> +    UnicodeString unicodeName;
> +    fICUTimeZone->getDisplayName(unicodeName);
> +
> +    BStringByteSink converter(&name);
> +    unicodeName.toUTF8(converter);
> +}
> +
> +
> +void
> +BTimeZone::Code(BString& code)
> +{
> +    UnicodeString unicodeName;
> +    fICUTimeZone->getID(unicodeName);
> +
> +    BStringByteSink converter(&code);
> +    unicodeName.toUTF8(converter);
> +}
> +
> +
> +int
> +BTimeZone::OffsetFromGMT()
> +{
> +    int32_t rawOffset;
> +    int32_t dstOffset;
> +    time_t now;
> +    UErrorCode error = U_ZERO_ERROR;
> +    fICUTimeZone->getOffset(time(&now) * 1000, FALSE, rawOffset, dstOffset
> +        , error);
> +    if (error != U_ZERO_ERROR)
> +        return 0;
> +    else
> +        return rawOffset + dstOffset;
> +}

Did you have any specific use case in mind that this class can serve? I 
tried to come up with one, but couldn't. 
The getter methods are so expensive that, if for instance an app wants to 
present a sorted list of timezones, it would require to wrap another 
struct/class around BTimeZone, as otherwise the sorting would be painfully 
slow. 

Then again, I might just be missing the intended purpose of BTimeZone.

If it indeed is just about passing on info about a specific timezone, I'd 
rather implement it either as a plain struct that exposes name, code and 
offset as elements or as a class which initializes these values as members 
in the constructor (or _Init()) and then provides getters to access them.

cheers,
        Oliver

Other related posts: