freenode/#lisp - IRC Chatlog
Search
17:33:02
jasom
Just so I don't reinvent the wheel; is there a library for giving the number of weekdays between two timestamps?
18:01:08
aeth
Fortunately, it's not as bad as it sounds because there are only about a dozen or two years. I guess there would be 14: a Jan 1 with each day of the week and the presence or absence of Feb 29. Intervals that cross multiple years could complicate things, though.
18:42:15
jackdaniel
https://github.com/McCLIM/McCLIM/blob/master/Core/clim-basic/extended-streams/text-formatting.lisp#L187
19:11:44
jackdaniel
ACTION desperately tries not to make a joke about comparing whose (implementation) is longer
19:38:38
jasom
xristos: I'm already using local-time, but it only has a single difference function and that only gives you the floor of the difference in years
19:49:45
_death
jasom: your best bet is to look at emacs's calendar code.. the authors also wrote a book called Calendrical Calculations and someone ported some of the code to CL https://gist.github.com/perusio/6687883
20:08:30
Xach
it is available online used for a few dollars. i think i will get a copy sometime soon.
20:08:36
ecraven
and the code is well-written, I "ported" it to Scheme (mostly just rewrite a few macros)
20:09:44
ecraven
I contacted one of the authors years ago about the Scheme port, he was very friendly, though I don't remember what he said exactly about the license
20:10:43
ecraven
ok, found the emails, he suggested that the port would still need to adhere to the original license (free for non-commercial use, I think)
20:13:10
ecraven
well, in theory, you could read the book (but not the code) and just implement the calculations yourself (depending on what exactly you need)
20:13:26
ecraven
the actual calendrical calculations are not so complex, mostly the sun/moon stuff is hard
20:14:08
ecraven
for number of weekdays, you "just" need to convert to rata die, calculate the difference, then check the weekdays
21:59:37
jasom
which is fine for my use case of "dozens of deltas with a difference of no more than a few months"
23:16:10
jasom
most of the ranges are on the order of a few days, so I don't see how precomputing would help
23:22:20
aeth
_death: There are, afaik, only 14 years. Jan 1st on each day of the week and the presence and absence of Feb 29th. So you could just store those and have rules for ranges that span multiple years.
23:23:00
aeth
holidays can be a separate pass, just subtract 1 if the holidy is in the range and on a weekday
23:28:15
_death
well, it's just a popcount to get weekdays in the representation I'm thinking of.. you could have one bitset for each calendar and union/intersect if needed
0:03:52
aeth
I was thinking about a "perpeutal calendar", which, as that page says, is a lookup table
0:07:12
aeth
_death: as I said, you can do a second pass to subtract holidays if it falls in the range.
0:11:58
_death
so having a bitset representation is convenient to allow such ad hoc changes.. in fact it could be made into a project resembling the time zone database, and become useful to many people.. maybe there's already a project like that
0:15:48
_death
though such a project could get more ambitious and need a more complex representation to support all kinds of annotations
0:32:27
MichaelRaskin
Note that some _parts_ of Germany have a ton of holidays of form Easter+N. The original meaning of holiday, yes. Different parts seem to have different amounts.
0:32:59
aeth
If you keep a database of holidays, congratulations, you have now chosen the project that will occupy you for the rest of your life.
0:33:45
MichaelRaskin
Then there is Russia where it is completely normal to have a working Saturday to bridge preceding Tuesday holiday with preceding weekend
0:35:48
Bike
this dream i had once where if you wrote something unoriginal you'd be eaten by a nuckelavee.
0:36:34
MichaelRaskin
This reminds me the story about greetings in an IRC channel where posting a line that has ever been posted leads to a kick
0:37:42
aeth
MichaelRaskin: alternatively, you can start with the most common line in any channel and work your way down from there...
1:05:19
aeth
srandon111: clisp is a great short name for Common Lisp, but unfortunately, CLISP is an implementation (and not the most popular one), so we tend to use CL
1:08:42
aeth
pjb: or you could call it, as a long name... COMMON Object-oriented Modern Mathematical Omnipresent Necessary Lisp
1:11:49
White_Flame
COMMON Object/Mathematical Manipulating Operational Notation LISP Integrating Symbolic Processing
1:15:02
aeth
I do like how that does explain everything you can do with it, too. OOP, functional programming ("mathematical"), and macros ("symbolic processing")
1:33:43
White_Flame
it's not as explanatory, but if doing & figuring out how it works is more your learning style, that can be good
1:35:10
White_Flame
as a learner, the differences between the various implementations aren't going to be noticeable
1:35:28
White_Flame
SBCL is certainly the most popular here, though, because of the fast code it generates
1:35:46
aeth
SBCL is more popular than CCL which is more popular than the rest, but of course exact numbers would be hard to find
1:36:05
srandon111
ok another thing... are there any advantages in learning common lisp wrt to clojure... i mean interms of libraries and modernity?
1:36:10
White_Flame
CCL had much stronger cross-platform support than SBCL, but I think the latter has basically caught up