• 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
Re: Thoroughly confused on date formatting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thoroughly confused on date formatting


  • Subject: Re: Thoroughly confused on date formatting
  • From: Jerry Krinock <email@hidden>
  • Date: Thu, 28 Sep 2006 19:12:29 -0700
  • Thread-topic: Thoroughly confused on date formatting

on 06/09/28 14:06, Mike Abdullah at email@hidden wrote:

> I want the user's preferred format, but without any sort of seconds
> setting, regardless of whether the user's settings specify seconds or
> not.
>
> The value I'm setting has no seconds value so it is pointless to
> display it to the user.  Honestly, NSDatePicker gets it just right

I think I've been through a similar mess.  Download the WBTimeController
which is available from White Box Software (Stephane Sudre), and look at
what they did.  It's not easy.  I added the following category which gave me
what I needed:

@implementation WBTimeControl (GimmeUsersPreferredTimeString)

- (NSString*)timeStringFormattedPerUserPrefs {
    //    Returns a string such as "9:05 PM" or "21;05"
    //    In Tiger, the clock format used by WBTimeControl depends on what
the user has set in:
    //    System Preferences > International> Formats > Times > Times >
Customize > Medium.
    //    I'm not sure how it will work in Panther but probably you ignore
the last selection,
    //    Medium.  I think that these per-length customizable formats
{Short, Medium, Long, Full}
    //    were added in Tiger.
    NSString* ampm ;
    NSString* space ;
    if (flags.is24Hour) {
        ampm = @"" ;
        space = @"" ;
    }
    else if ([self hour] > 12) {
        ampm = pmStr ;
        space = @" " ;
    }
    else {
        ampm = amStr ;
        space = @" " ;
    }
    NSString* string = [[NSString alloc] initWithFormat:@"%@%@%@%@%@",
        [self hourString:[self hour]],
        timeSeparatorStr,
        [self minuteString:[self minute]],
        space,
        ampm ] ;
    return [string autorelease] ;
}

@end



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Thoroughly confused on date formatting (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Truncating the string value of an NSTextField, in a Panther compatible way.
  • Next by Date: Re: Extracting Images from scanned PDF document
  • Previous by thread: Re: Thoroughly confused on date formatting
  • Next by thread: Re: Thoroughly confused on date formatting
  • Index(es):
    • Date
    • Thread