• 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
Date Formatter year input without year display
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Date Formatter year input without year display


  • Subject: Date Formatter year input without year display
  • From: Paul Bruneau <email@hidden>
  • Date: Wed, 10 Dec 2008 11:48:09 -0500

Hi-

I ran into a problem with my production scheduling application as the new year approached.

In IB I am using a 10.0 date formatter bound to NSDate properties of a model object.

I used: %1m/, %1I:%M%p

which gave me something like: 12/23, 12:30PM

This was used mostly for display, but the user is also able to type into the edit field in order to change the value.

As the new year came into play, he might have changed 12/23 to 1/5. My thinking was that if he entered just 1/5 it would assume the current year, which seems to be correct.

But I thought if he entered 1/5/2009, then Cocoa would help me out and do the right thing.

In fact, even when entering the year explicitly, the formatter still made the data be 1/5/2008.

I had to add the year to the formatter string to make it accept the year as input.

Is this expected? Is there a good way to only display the month and day, and yet allow the year to be entered if desired?

Thank you
_______________________________________________

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


  • Follow-Ups:
    • Re: Date Formatter year input without year display
      • From: Ashley Clark <email@hidden>
  • Prev by Date: Re: Problem drawing outside of drawRect: in a custom table cell
  • Next by Date: NSView subviews mutability - follow up to NSDictionary mutability test thread
  • Previous by thread: Re: [SOLVED] Re: NSTextField setStringValue not updating properly
  • Next by thread: Re: Date Formatter year input without year display
  • Index(es):
    • Date
    • Thread