polprog / osdp-roger-acs

BSD 3-Clause "New" or "Revised" License
4 stars 3 forks source link

Interested in time_expr #4

Open omnisci3nce opened 2 years ago

omnisci3nce commented 2 years ago

In user_db.c you mention a time_expr field but have the check in a TODO block.

Would you be able to expand a bit more on what you intend to do with that and how that might work?

polprog commented 2 years ago

This is for allowing access within some time period i elieve, after which the access token (card) is expired. @rpaciorek probably knows more.

rpaciorek commented 2 years ago

It will be text-based flexible way to describe the access schedule. For example (wd >0 && wd <6 && dmin>=420 && dmin <960) || (wd == 6 && dmin>=540 && dmin <840) will allow access on workdays (Monday to Friday) from 7AM to 4PM and on Saturday from 9AM to 2 PM.

Most likely it will be implemented before October.

omnisci3nce commented 2 years ago

I thought so. I have some experience with this and I've used this library before https://github.com/jakubroztocil/rrule which conforms to the iCal specification. You can see an example of what a rule string becomes such as DTSTART:20120201T093000Z\nRRULE:FREQ=WEEKLY;INTERVAL=5;UNTIL=20130130T230000Z;BYDAY=MO,FR

I wonder if there is a C library out there for iCal RFC compatible rules?

It might save you a fair bit of work by using a known standard for scheduling expressions as well as save time using code that already exists.