K
K
kovpas2011-01-11 17:11:07
iOS
kovpas, 2011-01-11 17:11:07

iPhone localization - date declination?

Good time of the day.
I ran into a problem - NSDateFormatter does not know how to inflect dates (why would he be able to, right?). That is, if I slip it a format like "MMMM yyyy", then the output is "January 2011". What are the solutions? And, yes, I really don’t want to make the code language-dependent, so I would like to consider the option with NSDictionary <January -> January> as a last resort.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
I
iStyx, 2011-01-12
@kovpas

NSDateFormatter *mf = [
NSString *dateString = [aDateFormatter stringFromDate:aDate];
In general, the symbol L is intended for stand-alone names (read without cases) (http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns)

S
Sergey Germanovich, 2014-09-16
@CHiPloveNY

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"LLL"]; //September

R
Rafael Osipov, 2011-01-11
@Rafael

If you don't want to implement language dependent mechanisms, then represent dates as numbers for the day, month, and year. The only thing that will need to be taken into account in the settings of your application in this case is the order of day-month-year and month-day-year.

S
Stanislav Suglobov, 2011-01-12
@suglosta

It looks like there is no standard solution in iOS.
It's strange that Apple didn't think of doing like Microsoft did in .NET, where the month format depends on the presence of a number in the string, that is,
'd MMMM yyyy' will give 'January 12, 2011', and
'MMMM yyyy' will give 'January 2011'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question