• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
What is returned from CFLocaleGetSystem?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What is returned from CFLocaleGetSystem?


  • Subject: What is returned from CFLocaleGetSystem?
  • From: Mark Schisler <email@hidden>
  • Date: Wed, 06 Jul 2011 11:46:04 -0400
  • Acceptlanguage: en-US
  • Thread-topic: What is returned from CFLocaleGetSystem?

When attempting to use CFLocaleGetSystem() as a parameter to
CFDateFormatterCreate(), a call to
CFDateFormatterGetAbsoluteTimeFromString() using the created
CFDateFormatterRef seemed to always return false.  However, when I changed
the code to use a locale created by CFLocaleCopyCurrent, formatting was
successful.  See my static C++ function below:

    GregorianDate GregorianDate::getFromFormat(
        const ReferenceCountedNonMutableString& date, const
ReferenceCountedNonMutableString& format) {

        CFAbsoluteTime absTime;
        CFGregorianDate gregDate;
        CFLocaleRef locale = CFLocaleGetSystem(); // or
CFLocaleCopyCurrent();

        CFDateFormatterRef dateFormatter = CFDateFormatterCreate(
           kCFAllocatorDefault, locale, kCFDateFormatterNoStyle,
kCFDateFormatterNoStyle);

        CFDateFormatterSetFormat(dateFormatter, format.getAsCFStringRef());
     	CFDateFormatterSetProperty(dateFormatter,kCFDateFormatterIsLenient,
kCFBooleanTrue);

        Boolean success =
CFDateFormatterGetAbsoluteTimeFromString(dateFormatter,
date.getAsCFStringRef(), NULL, &absTime);

        // return an invalid date
        if (!success)
        {
            return GregorianDate(0,0,0);
        }

        gregDate = CFAbsoluteTimeGetGregorianDate(absTime, NULL);

        CFRelease(dateFormatter);
        // CFRelease(locale);

        return GregorianDate(gregDate);
    }


The documentation states CFLocaleGetSystem returns "the root, canonical
locale", which "contains fixed backstop settings for all locale
information".  Clearly, this appears to be something different from the
current user locale.  My question is: is this a valid locale for anything?
 What is its use-case?

Thanks in advance!
Mark

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: [Moderator] Re: Lion's Auto Save & Versions
  • Next by Date: Re: Dynamically loading NIB files with a common stem
  • Previous by thread: Re: Core Data Predicate Question
  • Next by thread: Custom crop box for UIImagePickerController
  • Index(es):
    • Date
    • Thread