remove duplicatesfromthe list generated by ICU. * BTimeZone : remove Code, rename Name to GetName. The class is likely to change again for further optimization. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37719 a95241bf-73f2-0310-859d-f6bbb57e9c96
52 lines
842 B
C++
52 lines
842 B
C++
/*
|
|
Copyright 2010, Adrien Destugues <[email protected]>
|
|
Distributed under the terms of the MIT License.
|
|
*/
|
|
|
|
|
|
#include <TimeZone.h>
|
|
|
|
#include <String.h>
|
|
|
|
#include <unicode/timezone.h>
|
|
#include <ICUWrapper.h>
|
|
|
|
|
|
BTimeZone::BTimeZone(const char* zoneCode)
|
|
{
|
|
fICUTimeZone = TimeZone::createTimeZone(zoneCode);
|
|
}
|
|
|
|
|
|
BTimeZone::~BTimeZone()
|
|
{
|
|
delete fICUTimeZone;
|
|
}
|
|
|
|
|
|
void
|
|
BTimeZone::GetName(BString& name)
|
|
{
|
|
UnicodeString unicodeName;
|
|
fICUTimeZone->getDisplayName(unicodeName);
|
|
|
|
BStringByteSink converter(&name);
|
|
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;
|
|
}
|