• 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: Obtain an NSDate object from any casually entered user string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Obtain an NSDate object from any casually entered user string


  • Subject: Re: Obtain an NSDate object from any casually entered user string
  • From: Sean McBride <email@hidden>
  • Date: Thu, 15 May 2014 11:48:12 -0400
  • Organization: Rogue Research Inc.

On Thu, 15 May 2014 07:53:01 -0500, Charles Srstka said:

>> 3. But sometimes the date of NSDataDetector is 12h ahead (again
>ignoring fractions of a second):
>>
>> "2014-05-15 07:52:18.658" →  "2014-05-15 19:52:18  +0700"
>> "2014-05-14 05:59:46.490 +0700" → "2014-05-14 17:59:46.490 +0700"
>>
>> But not always - these work ok:
>> "2014-05-15 08:22:48.135"
>> "2014-05-15 09:15:35 +0700"
>> Also, all times after about 13:00 are correct.
>>
>> This arbitrary advancement of 12h is obviously NOT acceptable.
>> What am I doing wrong?
>
>That's the trouble with accepting arbitrary user input. If a user enters
>a time of "1:23", s/he might mean 1:23 AM, 1:23 PM, or 1:23 military
>time, and there's no real way to determine which is intended without
>reading the user's mind. So, the system has to guess. Sometimes it may
>not guess correctly.

True.  But it's a pretty strange guess that "2014-05-15 07:52:18.658" is afternoon.  If the user uses an am/pm system, then it's 50/50.  If the user uses a 24 hour system, there's no ambiguity.  So it's more probably a morning time.

Also, the guessing logic should check if the user uses 24 hour clock, which maybe it does or maybe not.

Cheers,

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada

_______________________________________________

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


References: 
 >Re: Obtain an NSDate object from any casually entered user string (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: Obtain an NSDate object from any casually entered user string (From: Charles Srstka <email@hidden>)

  • Prev by Date: White rectangle behind UIAlertView when subview clipsToBounds
  • Next by Date: Re: How to speak Chinese on 10.9.2
  • Previous by thread: Re: Obtain an NSDate object from any casually entered user string
  • Next by thread: DNS Lookup
  • Index(es):
    • Date
    • Thread