System Date/Time Format Problems

Pete pete at mollysrevenge.com
Sun Jul 3 17:58:14 EDT 2011


I think I already mentioned this but I've entered QC report number 9604
about all this.  There's various problems involved:

1) LC needs one more keyword so it can deal with the 4 date/time formats
used by OS X.
2) There's a bug in the "abbrev system time" - it returns LC's default
abbrev format, not the format in any of the OS X user preferences.
3) There's an inconsistency between the long system date and the long system
time - the date returned is in the OS X full format, and the time is in the
OS X medium format.

These issues occur anywhere you refer to system dates and times, including
the convert command.

Jacque - thanks for your code - it works pretty well for standard US
settings, as you said, but it doesn't help if the user has customised the
System Preferences date and time formats or if they are not using US
formats.  My objective is to allow the user to tell me that dates are to be
displayed in any one of the System Preference settings (or set a custom one
of their own).  I've figured out how to get the user's System Preference
settings from a combination of the shell locale command and an Applescript
and am busy writing a handler to format dates accordingly.

Pete
Molly's Revenge <http://www.mollysrevenge.com>




On Sun, Jul 3, 2011 at 11:14 AM, Pete <pete at mollysrevenge.com> wrote:

> Thanks Jacque, that's a great start.  I also found the dateFormat function
> which I think may assist in all this.
> Pete
> Molly's Revenge <http://www.mollysrevenge.com>
>
>
>
>
> On Sat, Jul 2, 2011 at 8:15 PM, J. Landman Gay <jacque at hyperactivesw.com>wrote:
>
>> On 7/2/11 2:46 PM, Pete wrote:
>>
>>  So if a user tells me he wants his dates in OS X medium or long format, I
>>> can't find out what that is with LC code, same for an OS X long time.
>>>
>>
>> Start with these. The functions below will only work on US systems, or in
>> countries that use US date/time formats. If you want to accomodate other
>> countries you'll have to do more work.
>>
>> The "lookupZone" function is for the long and full time formats. I have
>> exactly one entry in there for central time. What you need to do for that is
>> make a list of all the time zones, one per line, in the same order my
>> example uses. Store it in a custom property or somewhere. Retrieve the list
>> for the lookup function.
>>
>> There may be a shell call to do that, or a list stored somewhere in OS X.
>> I don't know. Anyway, maybe this will get you started:
>>
>> function formatDate pDate,pFormat -- short, medium, long, full
>>  switch pFormat
>>    case "short"
>>      convert pDate to short date
>>      put pDate into tFormattedDate
>>      break
>>    case "medium"
>>      convert pDate to abbrev date
>>      put item 2 to -1 of pDate into tFormattedDate
>>      break
>>    case "long"
>>      convert pDate to long date
>>      put item 2 to -1 of pDate into tFormattedDate
>>      break
>>    case "full"
>>      convert pDate to long date
>>      put pDate into tFormattedDate
>>      break
>>  end switch
>>  return tFormattedDate
>> end formatDate
>>
>> function formatTime pTime,pFormat
>>  switch pFormat
>>    case "short"
>>      convert pTime to short time
>>      put pTime into tFormattedTime
>>      break
>>    case "medium"
>>      convert pTime to long time
>>      put pTime into tFormattedTime
>>      break
>>    case "long"
>>    case "full"
>>      convert pTime to long time
>>      put pTime into tFormattedTime
>>      convert pTime to internet date
>>      put word 6 of pTime into tTimeZone
>>      put lookupZone(tTimeZone) into tZoneInfo
>>      if pFormat = "long" then
>>        put item 2 of tZoneInfo into tTimeZone
>>      else -- full
>>        put item 3 of tZoneInfo into tTimeZone
>>      end if
>>      put space & tTimeZone after tFormattedTime
>>      break
>>  end switch
>>  return tFormattedTime
>> end formatTime
>>
>> function lookupZone pHourOffset
>>  -- need a list in this format, one line per zone:
>>  put "-0500,CST,CT" into tZones
>>  return line lineoffset(pHourOffset,tZones) of tZones
>> end lookupZone
>>
>>
>> --
>> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
>> HyperActive Software           |     http://www.hyperactivesw.com
>>
>> ______________________________**_________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/**mailman/listinfo/use-livecode<http://lists.runrev.com/mailman/listinfo/use-livecode>
>>
>>
>



More information about the use-livecode mailing list