sl@0: /* sl@0: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: Contains the source for LC_TIME category related functions sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include "localeinfo.h" sl@0: #include "timelocal.h" sl@0: sl@0: #if (defined(__SYMBIAN32__) && (defined(__WINSCW__) || defined(__WINS__))) sl@0: #include "libc_wsd_defs.h" sl@0: #endif sl@0: sl@0: extern int __nlocale_changed; sl@0: #ifdef EMULATOR sl@0: int *GET_WSD_VAR_NAME(__nlocale_changed, g)(); sl@0: #define __nlocale_changed (*GET_WSD_VAR_NAME(__nlocale_changed, g)()) sl@0: #endif //EMULATOR sl@0: sl@0: #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT sl@0: extern unsigned char __clocale_set; sl@0: #ifdef EMULATOR sl@0: unsigned char *GET_WSD_VAR_NAME(__clocale_set, g)(); sl@0: #define __clocale_set (*GET_WSD_VAR_NAME(__clocale_set, g)()) sl@0: #endif //EMULATOR sl@0: #endif sl@0: #ifndef EMULATOR sl@0: int _time_using_locale = 0; sl@0: #else //EMULATOR sl@0: sl@0: GET_GLOBAL_VAR_FROM_TLS(_time_using_locale, int) sl@0: #define _time_using_locale (*GET_WSD_VAR_NAME(_time_using_locale, g)()) sl@0: #endif //EMULATOR sl@0: sl@0: static const struct lc_time_T _C_time_locale = { sl@0: { sl@0: "Jan", "Feb", "Mar", "Apr", "May", "Jun", sl@0: "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" sl@0: }, { sl@0: "January", "February", "March", "April", "May", "June", sl@0: "July", "August", "September", "October", "November", "December" sl@0: }, { sl@0: "Sun", "Mon", "Tue", "Wed", sl@0: "Thu", "Fri", "Sat" sl@0: }, { sl@0: "Sunday", "Monday", "Tuesday", "Wednesday", sl@0: "Thursday", "Friday", "Saturday" sl@0: }, sl@0: sl@0: /* X_fmt */ sl@0: "%H:%M:%S", sl@0: sl@0: /* sl@0: * x_fmt sl@0: * Since the C language standard calls for sl@0: * "date, using locale's date format," anything goes. sl@0: * Using just numbers (as here) makes Quakers happier; sl@0: * it's also compatible with SVR4. sl@0: */ sl@0: "%m/%d/%y", sl@0: sl@0: /* sl@0: * c_fmt sl@0: */ sl@0: "%a %b %e %H:%M:%S %Y", sl@0: sl@0: /* am */ sl@0: "AM", sl@0: sl@0: /* pm */ sl@0: "PM", sl@0: sl@0: /* date_fmt */ sl@0: "%a %b %e %H:%M:%S %Z %Y", sl@0: sl@0: /* alt_month sl@0: * Standalone months forms for %OB sl@0: */ sl@0: { sl@0: "January", "February", "March", "April", "May", "June", sl@0: "July", "August", "September", "October", "November", "December" sl@0: }, sl@0: sl@0: /* md_order sl@0: * Month / day order in dates sl@0: */ sl@0: "md", sl@0: sl@0: /* ampm_fmt sl@0: * To determine 12-hour clock format time (empty, if N/A) sl@0: */ sl@0: "%I:%M:%S %p" sl@0: }; sl@0: sl@0: struct lc_time_T * sl@0: __get_current_time_locale(void) sl@0: { sl@0: #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT sl@0: TInt ret; sl@0: #endif sl@0: //retrieve time(LC_TIME category) related information sl@0: if(_time_using_locale) sl@0: { sl@0: return (CLocale::GetCurrentTimeLocale()); sl@0: } sl@0: #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT sl@0: else if(__clocale_set) sl@0: #endif sl@0: //Retrieve POSIX locale time(LC_TIME) information sl@0: return (struct lc_time_T *)&_C_time_locale; sl@0: #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT sl@0: else sl@0: { sl@0: CLocale *l=CLocale::GetInstance(); sl@0: ret=l->SyncLocale(ELocaleLanguageSettings); sl@0: if(ret==-1) sl@0: return NULL; sl@0: TRAPD(result, l->TimeLoadLocaleL(NULL)); sl@0: if((result != KErrNone)) sl@0: return NULL; sl@0: return (CLocale::GetCurrentTimeLocale()); sl@0: } sl@0: #endif sl@0: } sl@0: sl@0: int sl@0: __time_load_locale(const char* localeName) sl@0: { sl@0: sl@0: CLocale* locale = CLocale::GetInstance(); sl@0: //Set time(LC_TIME category) related information sl@0: TInt ret=KErrNone; sl@0: TRAPD(result,ret = locale->TimeLoadLocaleL(localeName)); sl@0: if((result != KErrNone) || (ret == -1)) sl@0: { sl@0: return -1; sl@0: } sl@0: _time_using_locale = 1; sl@0: return 0; sl@0: sl@0: }