Re: date libraries/routines for LCG

2018-05-09 Thread Bob Sneidar via use-livecode
Yes, I contributed to the Master Library a couple of date and time functions 
which return formats which LC does not provide. One is sql date which returns 
the date in the format -mm-dd, The second is julian date which uses Jacques 
method (I understand there is not simply one Julian standard!) 

For time I have sql time (hh:mm:ss) and military, returning the time in 24 hour 
format. 

So for instance you can convert to sql datetime format by using formatDate(the 
date, "sql date) && formatTime(the time, "sql time"). 

I'm not sure if the Master Library made some improvement on the functions I 
submitted, but here is what I have:

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

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
   */
   if theTime is empty then return empty
   
   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 May 8, 2018, at 18:14 , Mike Doub via use-livecode 
>  wrote:
> 
> Have you checked the Master Library?
> 
> https://www.dropbox.com/s/3wpwn3hfbmpl7sk/MasterLibrary.livecode?dl=0


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

Re: date libraries/routines for LCG

2018-05-09 Thread ELS prothero via use-livecode
Dave:
Done.
Bill

William Prothero, PhD
Professor Emeritus
University of California, Santa Barbara
http://earthlearningsolutions.org

> On May 9, 2018, at 8:32 AM, Mike Kerner via use-livecode 
>  wrote:
> 
> Thank you...
> 
> On Wed, May 9, 2018 at 11:29 AM Brian Milby via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> 
>> Is this one on your list?
>> 
>> LiveCode library to handle date and time functions
>> https://github.com/derbrill/libdate
>> 
>> On Wed, May 9, 2018 at 8:57 AM Mike Kerner via use-livecode <
>> use-livecode@lists.runrev.com> wrote:
>> 
>>> Yep, Master is on my list, but I should make sure I pull the latest
>>> version.
>>> 
>>> On Tue, May 8, 2018 at 9:14 PM Mike Doub via use-livecode <
>>> use-livecode@lists.runrev.com> wrote:
>>> 
 Have you checked the Master Library?
 
 https://www.dropbox.com/s/3wpwn3hfbmpl7sk/MasterLibrary.livecode?dl=0
 
 On May 8, 2018, 9:10 PM -0400, Mike Kerner via use-livecode <
 use-livecode@lists.runrev.com>, wrote:
> I'm working on my session for next week's lcg, which is going to
>> focus
>>> on
> dates. I'd like to feature any libraries or routines that anyone
>> wants
>>> to
> share that have to do with dates.
> Please email me at one of my 300 email addresses.
> 
> --
> On the first day, God created the heavens and the Earth
> On the second day, God created the oceans.
> On the third day, God put the animals on hold for a few hours,
> and did a little diving.
> And God said, "This is good."
> ___
> 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
 
>>> 
>>> 
>>> --
>>> On the first day, God created the heavens and the Earth
>>> On the second day, God created the oceans.
>>> On the third day, God put the animals on hold for a few hours,
>>>   and did a little diving.
>>> And God said, "This is good."
>>> ___
>>> 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
>> 
> 
> 
> -- 
> On the first day, God created the heavens and the Earth
> On the second day, God created the oceans.
> On the third day, God put the animals on hold for a few hours,
>   and did a little diving.
> And God said, "This is good."
> ___
> 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: date libraries/routines for LCG

2018-05-09 Thread Mike Kerner via use-livecode
Thank you...

On Wed, May 9, 2018 at 11:29 AM Brian Milby via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Is this one on your list?
>
> LiveCode library to handle date and time functions
> https://github.com/derbrill/libdate
>
> On Wed, May 9, 2018 at 8:57 AM Mike Kerner via use-livecode <
> use-livecode@lists.runrev.com> wrote:
>
> > Yep, Master is on my list, but I should make sure I pull the latest
> > version.
> >
> > On Tue, May 8, 2018 at 9:14 PM Mike Doub via use-livecode <
> > use-livecode@lists.runrev.com> wrote:
> >
> > > Have you checked the Master Library?
> > >
> > > https://www.dropbox.com/s/3wpwn3hfbmpl7sk/MasterLibrary.livecode?dl=0
> > >
> > > On May 8, 2018, 9:10 PM -0400, Mike Kerner via use-livecode <
> > > use-livecode@lists.runrev.com>, wrote:
> > > > I'm working on my session for next week's lcg, which is going to
> focus
> > on
> > > > dates. I'd like to feature any libraries or routines that anyone
> wants
> > to
> > > > share that have to do with dates.
> > > > Please email me at one of my 300 email addresses.
> > > >
> > > > --
> > > > On the first day, God created the heavens and the Earth
> > > > On the second day, God created the oceans.
> > > > On the third day, God put the animals on hold for a few hours,
> > > > and did a little diving.
> > > > And God said, "This is good."
> > > > ___
> > > > 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
> > >
> >
> >
> > --
> > On the first day, God created the heavens and the Earth
> > On the second day, God created the oceans.
> > On the third day, God put the animals on hold for a few hours,
> >and did a little diving.
> > And God said, "This is good."
> > ___
> > 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
>


-- 
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
___
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: date libraries/routines for LCG

2018-05-09 Thread Brian Milby via use-livecode
Is this one on your list?

LiveCode library to handle date and time functions
https://github.com/derbrill/libdate

On Wed, May 9, 2018 at 8:57 AM Mike Kerner via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Yep, Master is on my list, but I should make sure I pull the latest
> version.
>
> On Tue, May 8, 2018 at 9:14 PM Mike Doub via use-livecode <
> use-livecode@lists.runrev.com> wrote:
>
> > Have you checked the Master Library?
> >
> > https://www.dropbox.com/s/3wpwn3hfbmpl7sk/MasterLibrary.livecode?dl=0
> >
> > On May 8, 2018, 9:10 PM -0400, Mike Kerner via use-livecode <
> > use-livecode@lists.runrev.com>, wrote:
> > > I'm working on my session for next week's lcg, which is going to focus
> on
> > > dates. I'd like to feature any libraries or routines that anyone wants
> to
> > > share that have to do with dates.
> > > Please email me at one of my 300 email addresses.
> > >
> > > --
> > > On the first day, God created the heavens and the Earth
> > > On the second day, God created the oceans.
> > > On the third day, God put the animals on hold for a few hours,
> > > and did a little diving.
> > > And God said, "This is good."
> > > ___
> > > 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
> >
>
>
> --
> On the first day, God created the heavens and the Earth
> On the second day, God created the oceans.
> On the third day, God put the animals on hold for a few hours,
>and did a little diving.
> And God said, "This is good."
> ___
> 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: date libraries/routines for LCG

2018-05-09 Thread Mike Kerner via use-livecode
Yep, Master is on my list, but I should make sure I pull the latest version.

On Tue, May 8, 2018 at 9:14 PM Mike Doub via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Have you checked the Master Library?
>
> https://www.dropbox.com/s/3wpwn3hfbmpl7sk/MasterLibrary.livecode?dl=0
>
> On May 8, 2018, 9:10 PM -0400, Mike Kerner via use-livecode <
> use-livecode@lists.runrev.com>, wrote:
> > I'm working on my session for next week's lcg, which is going to focus on
> > dates. I'd like to feature any libraries or routines that anyone wants to
> > share that have to do with dates.
> > Please email me at one of my 300 email addresses.
> >
> > --
> > On the first day, God created the heavens and the Earth
> > On the second day, God created the oceans.
> > On the third day, God put the animals on hold for a few hours,
> > and did a little diving.
> > And God said, "This is good."
> > ___
> > 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
>


-- 
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
___
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: date libraries/routines for LCG

2018-05-08 Thread Mike Doub via use-livecode
Have you checked the Master Library?

https://www.dropbox.com/s/3wpwn3hfbmpl7sk/MasterLibrary.livecode?dl=0

On May 8, 2018, 9:10 PM -0400, Mike Kerner via use-livecode 
, wrote:
> I'm working on my session for next week's lcg, which is going to focus on
> dates. I'd like to feature any libraries or routines that anyone wants to
> share that have to do with dates.
> Please email me at one of my 300 email addresses.
>
> --
> On the first day, God created the heavens and the Earth
> On the second day, God created the oceans.
> On the third day, God put the animals on hold for a few hours,
> and did a little diving.
> And God said, "This is good."
> ___
> 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