Start of a date handling library

Are you developing tools to extend the LiveCode environment? This is the place to talk about the nuts and bolts of extending our nuts and bolts. If you want to use a LiveCode or third party Environment extension, visit the Using Evironment Extensions forum.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Start of a date handling library

Post by malte » Fri Jun 28, 2013 11:38 pm

Hi all,


[update]Libdate is now on gitHub

https://github.com/derbrill/libdate

[/update]
as I currently (again) stumbled over the limits of the convert command (on windows no dates before 01/01/1970 can be converted) I started on a small library to handle dates. I will try to attach the stack here.

[update August 01 2014]
I have put quite some work into the lib. There is still quite a bit to do, however it is worth downloading the update:
Handler and Function names have been cleaned up. Also a parser has been added to finally get rid of the convert command as good as possible. I need your help now! I would like to add parsing for as many different languages I can get.

If you are using operating systems set to languages other than english, swedish or german, could you please be so kind to post:

the system dateFormat
the long system dateFormat
the abbrev system dateFormat
the system monthNames
the abbrev system monthNames
the system weekDayNames
the abbrev system weekDayNames

on your machines, along with the language you are using on your system and if possible the ISO code for that language? That would be a great help!

[/update]

[update]
I will always attach the most current version of the library to this post.

June 4th 2013:

New functions added:
libDate_DaysBetween -> returns the number of days between 2 dates
libDate_DateInDaysFrom -> returns the date in a number of days
libDate_DaysOfCalendarWeekIso -> returns the dates in a specific calendar week (ISO Format)

Helper functions:
libDate_DayNumber -> returns a numeric value for a date
libDate_DateFromNumber -> inverse function of the above

[/update]
Attachments
libDate.rev.zip
(8.52 KiB) Downloaded 289 times
Last edited by malte on Wed Apr 01, 2015 11:24 am, edited 4 times in total.

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Start of a date handling library

Post by malte » Fri Jun 28, 2013 11:40 pm

Library attached. It is released into the public domain. No strings attached. No warranty. There is a button to test each function that is implemented. I am looking forward to feedback and contributions if you would like to help out.

Cheers,

Malte

[update] Updated the library. You can find it below[/update]
Last edited by malte on Sat Jun 29, 2013 8:25 pm, edited 1 time in total.

wilstrand
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 114
Joined: Mon Jan 03, 2011 3:02 pm
Contact:

Re: Start of a date handling library

Post by wilstrand » Fri Jun 28, 2013 11:53 pm

Hi Malte!

Thanks for this fine contribution to the community! It is something much needed.

All the best!

Mats
http:www.tapirsoft.on-rev.com
Open Source LiveCode Plugins - rIDE, rGrid, rTree
LiveCode projects

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3406
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Start of a date handling library

Post by bn » Sat Jun 29, 2013 12:26 am

Hi Malte,

thank you very much for sharing, very useful.
Finally I know that I was born on the 190th day in isoCalenderweek 27. :) :)

One little problem.
you have two buttons "libDate_AbbrevSystemWeekdayName" the first one throws an error because of "libDate_CalendarWeek" there is no handler for this call. What did you want to do there?

Kind regards
Bernd

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Start of a date handling library

Post by malte » Sat Jun 29, 2013 12:38 am

Ah, drats. :-) That one is a leftover. I first wanted to call the funcion libDate_CalendarWeek, but that would be misleading, as in the US the calendar week is counted differently. So I added the ISO Postfix and forrgot to throw out the button.

What I plan now is to have a set of handlers for converions between dates and for date validation. This is really just a first step, but thee is a couple of things I need which might Predate 1970 or Postdate 2035, so I can not rely on the convert command. :-)

Best,

Malte

sbrand
Posts: 1
Joined: Sun May 17, 2009 5:00 am
Contact:

Re: Start of a date handling library

Post by sbrand » Sat Jun 29, 2013 1:03 am

Hi Malte,

I am checking this out in LC Community 6.1 (dp2)

Checked each button and the dates work great! Nice having dates that go further back in time.

Your buttons - there are two buttons that state libDate_AbbrevSystemWeekdayName - from the top down: the first button throws this error:

button "libDate_AbbrevSystemWeekdayName": execution error at line 6 (Function: error in function handler) near "libDate_CalendarWeek", char 8

The second one or bottom one works fine!

cheers,
Scott
spookaw

PBH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 110
Joined: Sun Feb 20, 2011 4:26 pm
Location: Vancouver Island, BC, Canada. ex.UK
Contact:

Re: Start of a date handling library

Post by PBH » Sat Jun 29, 2013 1:53 am

Thown out the extra button and it works great.

Thank you very much for sharing. :-)

Paul

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Start of a date handling library

Post by malte » Sat Jun 29, 2013 8:16 pm

thanks for the feedback guys. So what else is needed. I want to write conversion routines to transform dates from one date into another. This will be tricky to come up with proper syntax though. Any suggestions very welcome.

Best,

Malte

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Start of a date handling library

Post by malte » Sat Jun 29, 2013 8:24 pm

Mats just reported an error. short english returned the long format. This is now fixed. The extra button has been removed. The update is attached to the first post of this thread.

Cheers,

malte

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5562
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Start of a date handling library

Post by jacque » Sat Jun 29, 2013 8:46 pm

Very cool Malte, thanks much. I didn't know I was born on a Thursday until now. :)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Partenaire
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 33
Joined: Tue Apr 17, 2012 9:50 am
Location: SAINT NAZAIRE FRANCE

Re: Start of a date handling library

Post by Partenaire » Sun Jun 30, 2013 11:10 am

Hello Malte,

Thank you for libDate, very useful and simple to use. Work fine.

Warms Regards
Eric

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Location: Plymouth, UK
Contact:

Re: Start of a date handling library

Post by dave.kilroy » Sun Jun 30, 2013 9:20 pm

Hi Malte

Very nice, thanks for sharing - have discovered my wife and I were both born on a Thursday :)
"...this is not the code you are looking for..."

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Start of a date handling library

Post by malte » Mon Jul 01, 2013 12:09 pm

Glad to hear it is useful. What else do you all think is needed?

wilstrand
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 114
Joined: Mon Jan 03, 2011 3:02 pm
Contact:

Re: Start of a date handling library

Post by wilstrand » Mon Jul 01, 2013 10:17 pm

Hi Malte!

I would love to have a weekDates function, returning the dates of a week. It would simplify building a month view a great deal.

Thanks again for this fine lib!

Best
Mats
http:www.tapirsoft.on-rev.com
Open Source LiveCode Plugins - rIDE, rGrid, rTree
LiveCode projects

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Start of a date handling library

Post by malte » Mon Jul 01, 2013 11:25 pm

Hey Mats,

what would you like as a return value?


Best,

Malte

Post Reply

Return to “Making IDE Plugins”