Page 1 of 3

Start of a date handling library

Posted: Fri Jun 28, 2013 11:38 pm
by malte
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]

Re: Start of a date handling library

Posted: Fri Jun 28, 2013 11:40 pm
by malte
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]

Re: Start of a date handling library

Posted: Fri Jun 28, 2013 11:53 pm
by wilstrand
Hi Malte!

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

All the best!

Mats

Re: Start of a date handling library

Posted: Sat Jun 29, 2013 12:26 am
by bn
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

Re: Start of a date handling library

Posted: Sat Jun 29, 2013 12:38 am
by malte
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

Re: Start of a date handling library

Posted: Sat Jun 29, 2013 1:03 am
by sbrand
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

Re: Start of a date handling library

Posted: Sat Jun 29, 2013 1:53 am
by PBH
Thown out the extra button and it works great.

Thank you very much for sharing. :-)

Paul

Re: Start of a date handling library

Posted: Sat Jun 29, 2013 8:16 pm
by malte
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

Re: Start of a date handling library

Posted: Sat Jun 29, 2013 8:24 pm
by malte
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

Re: Start of a date handling library

Posted: Sat Jun 29, 2013 8:46 pm
by jacque
Very cool Malte, thanks much. I didn't know I was born on a Thursday until now. :)

Re: Start of a date handling library

Posted: Sun Jun 30, 2013 11:10 am
by Partenaire
Hello Malte,

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

Warms Regards
Eric

Re: Start of a date handling library

Posted: Sun Jun 30, 2013 9:20 pm
by dave.kilroy
Hi Malte

Very nice, thanks for sharing - have discovered my wife and I were both born on a Thursday :)

Re: Start of a date handling library

Posted: Mon Jul 01, 2013 12:09 pm
by malte
Glad to hear it is useful. What else do you all think is needed?

Re: Start of a date handling library

Posted: Mon Jul 01, 2013 10:17 pm
by wilstrand
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

Re: Start of a date handling library

Posted: Mon Jul 01, 2013 11:25 pm
by malte
Hey Mats,

what would you like as a return value?


Best,

Malte