Re: ISO 8601 date to seconds

2015-02-05 Thread Bob Sneidar
It’s my understanding that sqLite accepts any value in any field type, whereas 
mySQL will toss an error and reject the SQL statement. Correct me if I am 
wrong, it’s happened before. 

Bob S


 On Jan 31, 2015, at 12:44 , Peter Haworth p...@lcsql.com wrote:
 
 On Sat, Jan 31, 2015 at 11:41 AM, Brahmanathaswami bra...@hindu.org wrote:
 
 FYI: those interested in this date/time enhancement can add their thoughts
 here:
 
 http://quality.runrev.com/show_bug.cgi?id=4636
 
 
 Just added one minor note.  The separator between date and time can be the
 letter T as well as a space.  SQLIte allows this, not sure about other
 implementations.
 
 Pete
 lcSQL Software http://www.lcsql.com
 Home of lcStackBrowser http://www.lcsql.com/lcstackbrowser.html and
 SQLiteAdmin http://www.lcsql.com/sqliteadmin.html
 ___
 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

___
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

Re: ISO 8601 date to seconds

2015-01-31 Thread Brahmanathaswami
FYI: those interested in this date/time enhancement can add their 
thoughts here:


http://quality.runrev.com/show_bug.cgi?id=4636

Bob Sneidar wrote:

Sorry about the extra lines in the last post. Not sure what caused that. Here 
is the formatDate() function as well.

Bob S

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 -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 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



On Jan 29, 2015, at 08:05 , Bob Sneidarbobsnei...@iotecdigital.com  wrote:

Not that this solves your particular problem but some might be interested in 
this function. I will see if I can include this scenario in my function at some 
point.

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


___
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


Re: ISO 8601 date to seconds

2015-01-31 Thread Peter Haworth
On Sat, Jan 31, 2015 at 11:41 AM, Brahmanathaswami bra...@hindu.org wrote:

 FYI: those interested in this date/time enhancement can add their thoughts
 here:

 http://quality.runrev.com/show_bug.cgi?id=4636


Just added one minor note.  The separator between date and time can be the
letter T as well as a space.  SQLIte allows this, not sure about other
implementations.

Pete
lcSQL Software http://www.lcsql.com
Home of lcStackBrowser http://www.lcsql.com/lcstackbrowser.html and
SQLiteAdmin http://www.lcsql.com/sqliteadmin.html
___
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


Re: ISO 8601 date to seconds

2015-01-29 Thread Bob Sneidar
Sorry about the extra lines in the last post. Not sure what caused that. Here 
is the formatDate() function as well. 

Bob S

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 -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 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


 On Jan 29, 2015, at 08:05 , Bob Sneidar bobsnei...@iotecdigital.com wrote:
 
 Not that this solves your particular problem but some might be interested in 
 this function. I will see if I can include this scenario in my function at 
 some point.
 
 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


Re: ISO 8601 date to seconds

2015-01-29 Thread Bob Sneidar
Not that this solves your particular problem but some might be interested in 
this function. I will see if I can include this scenario in my function at some 
point.

Bob S

function formatTime theTime, theFormat
   /*
   accepts any valid time and returns the form of the time specified in the 
second parameter.
   The valid formats are:
   sql time: hh:mm:ss (Note: combining sql date from the formatDate() function 
with the
   sql time will produce a valid SQL date time type).
   short time: LC short time format
   abbreviated time: LC abbr time format (same as short time)
   long time: LC long time format
   seconds: the number of seconds since the prior midnight
   military: the military time 00:00 - 23:59
   */



   set the numberFormat to 00
   switch theFormat
  case sql time
 convert theTime to dateitems
 put (item 4 of theTime +0)  :  \
   (item 5 of theTime +0)  :  \
   (item 6 of theTime +0) into theTime
 break
  case short time
 convert theTime to short time
 break
  case abbreviated time
 convert theTime to abbreviated time
 break
  case long time
 convert theTime to long time
 break
  case seconds
 convert theTime to seconds
 break
  case military
 set the itemDelimiter to :



 if theTime contains PM then
add 12 to item 1 of theTime
 end if



 put word 1 of item 2 of theTime into item 2 of theTime
 break
   end switch



   return theTime
end formatTime


On Jan 28, 2015, at 21:28 , Geoff Canyon 
gcan...@gmail.commailto:gcan...@gmail.com wrote:

On Wed, Jan 28, 2015 at 8:12 PM, Brahmanathaswami 
bra...@hindu.orgmailto:bra...@hindu.org wrote:

2000-02-17T22:13:21-05

As anyone written a script to convert this to seconds?


If the positioning is fixed (as is implied by the leading 0s) then I think
this will work:

function S D
  put format(%s/%s/%s %s,char 6 to 7 of D,char 9 to 10 of D,char 1 to 4
of D,char 12 to 19 of D) into R
  convert R to seconds
  return R + 3600 * char -3 to -1 of D
end S
___
use-livecode mailing list
use-livecode@lists.runrev.commailto: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

___
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


Re: ISO 8601 date to seconds

2015-01-28 Thread J. Landman Gay

On 1/28/2015 8:12 PM, Brahmanathaswami wrote:

I have to deal with a lot date/time based algorithms on CentoOS/Word
Press (and other similar frameworks) where the Date is usually output
liked this, with no timezone code

2000-02-17T22:13:21-05

As anyone written a script to convert this to seconds? I need to compare
such a date with the time right now in LiveCode(server) and the only way
is via seconds.


This should work:

function convertDate pDate
  put char 1 to offset(T,pDate)-1 of pDate into tDate
  put char offset(T,pDate)+1 to -4 of pDate into tTime
  put char -3 to -1 of pDate into tHrOffset
  replace - with slash in tDate
  set the itemdel to slash
  put item 2 to 3 of tDate  slash  item 1 of tDate into tDate
  set the itemdel to comma
  convert (tDate  tTime) to dateitems
  add tHrOffset to item 4 of it
  convert it to seconds
  return it
end convertDate

If the time zone includes minutes, you'd need to extract those and add 
them to the minutes item of the dateitems, just before or after the 
hrOffset is added.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

___
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


Re: ISO 8601 date to seconds

2015-01-28 Thread Geoff Canyon
On Wed, Jan 28, 2015 at 8:12 PM, Brahmanathaswami bra...@hindu.org wrote:

 2000-02-17T22:13:21-05

 As anyone written a script to convert this to seconds?


If the positioning is fixed (as is implied by the leading 0s) then I think
this will work:

function S D
   put format(%s/%s/%s %s,char 6 to 7 of D,char 9 to 10 of D,char 1 to 4
of D,char 12 to 19 of D) into R
   convert R to seconds
   return R + 3600 * char -3 to -1 of D
end 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