(oops, the previous version truncated part of the API)
Here is the current API with the changes per the requests in the ICU PMC 2012-02-15. Yoshito wonders whether the API really needs to support multiple pairs of context type and corresponding value - perhaps it should just support capitalization context (though this would mean additional format methods if we added, say, grammatical context).
- Peter E
==== ICU4C i18n udat.h ====
enum UDateFormatContextType {
UDAT_CAPITALIZATION = 1
};
enum UDateFormatContextValue {
// values for UDateFormatContextType
UDAT_CONTEXT_UNKNOWN = 0,
// values for UDAT_CAPITALIZATION
UDAT_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE = 1,
UDAT_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE = 2,
UDAT_CAPITALIZATION_FOR_UI_LIST_OR_MENU = 3,
UDAT_CAPITALIZATION_FOR_STANDALONE = 4
};
void
udat_setContext(UDateFormat* fmt,
UDateFormatContextType type, UDateFormatContextValue value,
UErrorCode& status);
int32_t
udat_getContext(UDateFormat* fmt,
UDateFormatContextType type,
UErrorCode& status);
==== ICU4C i18n SimpleDateFormat ====
virtual void
setContext(UDateFormatContextType type, UDateFormatContextValue value,
UErrorCode& status);
virtual int32_t
getContext(UDateFormatContextType type,
UErrorCode& status) const;
virtual UnicodeString&
format(Calendar& cal,
const UDateFormatContextType* types, // parallel lists of
const UDateFormatContextValue* values, // types and values
int32_t typesAndValuesCount,
UnicodeString& appendTo, FieldPosition& pos) const;
==== ICU4J SimpleDateFormat ====
public enum ContextType {
CAPITALIZATION
}
public enum ContextValue {
/** Values for any ContextType (key) */
UNKNOWN,
/** Values for context type (key) CAPITALIZATION */
CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE,
CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE,
CAPITALIZATION_FOR_UI_LIST_OR_MENU,
CAPITALIZATION_FOR_STANDALONE
}
public void
setDefaultContext(ContextType type, ContextValue value);
public ContextValue
getDefaultContext(ContextType type);
public StringBuffer
format(Calendar cal, Map<ContextType,ContextValue> contextValues,
StringBuffer toAppendTo, FieldPosition pos);
====
On Feb 22, 2012, at 12:17 PM, Peter Edberg wrote:
> Here is the current API with the changes per the requests in the ICU PMC. Yoshito wonders whether the API really needs to support multiple pairs of context type and corresponding value - perhaps it should just support capitalization context (though this would mean additional format methods if we added, say, grammatical context).
>
> <API list was truncated>
>
>
> On Feb 19, 2012, at 9:54 PM, Peter Edberg wrote:
>
>> I have one minor suggested change, to rename the enum types to add "Format", e.g. UDateContextType -> UDateFormatContextType, UDateContextValue -> UDateFormatContextValue. This more closely matches the existing DateFormat enum types.
>>
>> Any objections?
>> - Peter E
>>
>>
>> On Feb 17, 2012, at 2:23 PM, yoshito_umaoka@... wrote:
>>
>>> This proposal was approved by ICU PMC on 2012-02-15 with following updates:
>>>
>>> - Add enum for default context - UDAT_CAPITALIZATION_UNKNOWN
>>> - Use Java enum for context constants in ICU4J instead of int
>>> - Change set/getContext to set/getDefaultContext
>>> - Add one more format signature taking a context overriding the default context.
>>>
>>> -Yoshito
>>>
>>> Peter Edberg <pedberg@...> wrote on 02/13/2012 07:32:16 PM:
>>>
>>> > From: Peter Edberg <pedberg@...>
>>> > To: icu-design@...,
>>> > Date: 02/13/2012 07:33 PM
>>> > Subject: [icu-design] Date format functions to set/get context
>>> > (capitalization, grammar…)
>>> >
>>> > Ticket #9110
>>> > Designated reviewer: Yoshito
>>> > Feedback by Weds Feb. 15 if possible, else by Fri. Feb. 17
>>> >
>>> > For date/time formatting/parsing, we need to be able to specify
>>> > context such as capitalization context (in order to transform the
>>> > output per the data in the new CLDR contextTransforms element),
>>> > perhaps grammatical context, and others. (The same considerations
>>> > may apply to generating displayNames for languages, territories,
>>> > etc. but this does not attempt to address those - reserved for a
>>> > future proposal).
>>> > - Peter E
>>> >
>>> > ==== ICU4C i18n udat.h:
>>> >
>>> > enum UDateContextType {
>>> > UDAT_CAPITALIZATION = 1
>>> > };
>>> >
>>> > enum UDateContextValue {
>>> > // values for UDAT_CAPITALIZATION
>>> > UDAT_CAPITALIZATION_MIDDLE_OF_SENTENCE = 1,
>>> > UDAT_CAPITALIZATION_BEGINNING_OF_SENTENCE = 2,
>>> > UDAT_CAPITALIZATION_UI_LIST_OR_MENU = 3,
>>> > UDAT_CAPITALIZATION_STANDALONE = 4
>>> > };
>>> >
>>> > void udat_setContext( UDateFormat* fmt,
>>> > UDateContextType type, UDateContextValue value,
>>> > UErrorCode& status);
>>> >
>>> > int32_t udat_getContext( UDateFormat* fmt,
>>> > UDateContextType type,
>>> > UErrorCode& status);
>>> >
>>> > ==== ICU4C i18n SimpleDateFormat:
>>> >
>>> > virtual void setContext( UDateContextType type, UDateContextValue value,
>>> > UErrorCode& status);
>>> >
>>> > virtual int32_t getContext( UDateContextType type,
>>> > UErrorCode& status) const;
>>> >
>>> > ==== ICU4J DateFormat:
>>> >
>>> > public final static int DATE_CAPITALIZATION = 1;
>>> > public final static int DATE_CAPITALIZATION_MIDDLE_OF_SENTENCE = 1;
>>> > public final static int DATE_CAPITALIZATION_BEGINNING_OF_SENTENCE = 2;
>>> > public final static int DATE_CAPITALIZATION_UI_LIST_OR_MENU = 3;
>>> > public final static int DATE_CAPITALIZATION_STANDALONE = 4;
>>> >
>>> > ==== ICU4J SimpleDateFormat:
>>> >
>>> > public void setContext(int type, int value);
>>> >
>>> > public int getContext( int type);
>>> >
>>> >
>>> > ------------------------------------------------------------------------------
>>> > Keep Your Developer Skills Current with LearnDevNow!
>>> > The most comprehensive online learning library for Microsoft developers
>>> > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
>>> > Metro Style Apps, more. Free future releases when you subscribe now!
>>> > http://p.sf.net/sfu/learndevnow-d2d
>>> > _______________________________________________
>>> > icu-design mailing list
>>> > icu-design@...
>>> > To Un/Subscribe: https://lists.sourceforge.net/lists/listinfo/icu-design
>>> >
>>> ------------------------------------------------------------------------------
>>> Virtualization & Cloud Management Using Capacity Planning
>>> Cloud computing makes use of virtualization - but cloud computing
>>> also focuses on allowing computing to be delivered as a service.
>>> http://www.accelacomm.com/jaw/sfnl/114/51521223/_______________________________________________
>>> icu-design mailing list
>>> icu-design@...
>>> To Un/Subscribe: https://lists.sourceforge.net/lists/listinfo/icu-design
>>
>> ------------------------------------------------------------------------------
>> Try before you buy = See our experts in action!
>> The most comprehensive online learning library for Microsoft developers
>> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
>> Metro Style Apps, more. Free future releases when you subscribe now!
>> http://p.sf.net/sfu/learndevnow-dev2_______________________________________________
>> icu-design mailing list
>> icu-design@...
>> To Un/Subscribe: https://lists.sourceforge.net/lists/listinfo/icu-design
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/_______________________________________________
> icu-design mailing list
> icu-design@...
> To Un/Subscribe: https://lists.sourceforge.net/lists/listinfo/icu-design
|