This of course assumes you know tDate is supposed to be a short date. 

I also have this function which is part of the master library methinks:

function formatDate theDate, theFormat
   /*
   Accepts any valid date for the first parameter. If not a valid date, it 
simply returns
   what was passed. Second parameter can be any of the following:
   sql date: date in the yyyy-mm-dd format
   short date, abbreviated date, internet date, long date: LC versions of the 
same
   julian date: Julian number based on (I believe) Jacques formula)
   */
   
   put the itemdelimiter into theOldDelim
   set the itemdelimiter to "-"
   
   if the length of item 1 of theDate = 4 and \
         the number of items of theDate = 3 and \
         item 1 of theDate is a number and \
         item 2 of theDate is a number and \
         item 3 of theDate is a number then
      put item 2 of theDate & "/" & \
            item 3 of theDate & "/" & \
            item 1 of theDate into theDate
   end if
   
   convert theDate to dateitems
   set the itemdelimiter to theOldDelim
   
   switch theFormat
      case "sql date"
         put item 1 of theDate & "-" & \
               format("%02d",item 2 of theDate) & "-" & \
               format("%02d",item 3 of theDate) into theDate
         break
      case "short date"
         convert theDate from dateitems to short date
         break
      case "abbreviated date"
         convert theDate from dateitems to abbreviated date
         break
      case "abbr date"
         convert theDate from dateitems to abbreviated date
         break
      case "internet date"
         convert theDate from dateitems to internet date
         break
      case "long date"
         convert theDate from dateitems to long date
         break
      case "julian date"
         put the date into theDate
           convert theDate to dateItems
           if  ((item 2 of theDate = 1) or (item 2 of theDate = 2)) then
                 put 1 into theDay
           else
                 put 0 into theDay
           end if
           put item 1 of theDate + 4800 - theDay into theYear
           put item 2 of theDate + (12 * theDay) - 3 into theMonth
           put item 3 of theDate + \
                       ((153 * theMonth + 2) div 5) + \
                       (365 * theYear) + \
                       (theYear div 4) - \
                       (theYear div 100) + \
                       (theYear div 400) - \
                       32045 into theDate
         break
   end switch
   
   return theDate 
end formatDate

Bob S


> On Oct 16, 2017, at 09:47 , Bob Sneidar <bobsnei...@iotecdigital.com> wrote:
> 
> Old trick I learned in Foxpro. Convert something then convert it back and see 
> if it is identical. 
> 
> put 20 into tDate
> put tDate into tOldDate
> convert tDate to dateitems
> convert tDate to short date
> return ((tDate is a date) and (tDate is tOldDate))
> 
> Bob S
> 
> 


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to