Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Datepicker problem, set to NSGregorianCalendar but value send back is still NSBuddhis

saschasascha Posts: 42Registered Users
Hi,
I have phones that use the Buddhist Calendar, they are already in year 2555.
I can set the format of the datepicker to show the GregorianCalendar date (2012) but the value that the datepicker returns is still 2555.

I know I can convert the date from 1 to another in the background, but i would prefer to let datepicker just return me the right date.


Thanks
Sascha
Post edited by sascha on

Replies

  • DomeleDomele Posts: 2,948Registered Users
    Did you set the calendar property of the UIDatePicker?
    If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.



    New app - See screenshots and details at www.globaclock.com.



    If you want to
  • saschasascha Posts: 42Registered Users
    Domele;439016 said:
    Did you set the calendar property of the UIDatePicker?
    Hi
    Yes.
    What i did

    NSLocale *uk = [[NSLocale alloc] initWithLocaleIdentifier:@"en_GB"];
    NSCalendar *cal = [NSCalendar currentCalendar];
    [cal setLocale:uk];
    [uk release];
    [myDatePicker setCalendar:cal];
  • DomeleDomele Posts: 2,948Registered Users
    Use this:

    NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];


    By the way, please use code tags. [CODE] [1/CODE] Without the 1.
    If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.



    New app - See screenshots and details at www.globaclock.com.



    If you want to
  • saschasascha Posts: 42Registered Users
    Domele;439026 said:
    Use this:

    NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];


    By the way, please use code tags. [CODE] [1/CODE] Without the 1.
    That worked, plus i forgot to add it in another viewcontroller.

    Thanks
  • Duncan CDuncan C Posts: 8,031Tutorial Authors, Registered Users
    sascha;438964 said:
    Hi,
    I have phones that use the Buddhist Calendar, they are already in year 2555.
    I can set the format of the datepicker to show the GregorianCalendar date (2012) but the value that the datepicker returns is still 2555.

    I know I can convert the date from 1 to another in the background, but i would prefer to let datepicker just return me the right date.


    Thanks
    Sascha
    An NSdate object does not use a particular calendar. A date is a moment in time, expressed as a number of seconds since January 1, 2001 in GMT. You use a calendar object to interpret a date using a particular calendar.

    So by setting up your date picker in Gregorian, it lets the user describe the date in terms of the Gregorian calendar, but then if you pass that date to another system method, that method will display the date using whatever calendar it is set up to use. If a user's calendar is the Buddhist calendar then the date will be displayed in the Buddhist calendar unless you create a date formatter using a different calendar object.
    Regards,

    Duncan C
    WareTo

    mug

    Animated GIF created with Face Dancer, available for free in the app store.
Sign In or Register to comment.