eikek / calev Goto Github PK
View Code? Open in Web Editor NEWWork with systemd.time like calendar events in Scala
License: MIT License
Work with systemd.time like calendar events in Scala
License: MIT License
The readme shows a bug when generating events where there aren't any.
If an event is in the past, the nextElapsed returns a None:
CalEvent.unsafe("1900-01-* 12,14:0:0").nextElapse(LocalDateTime.now) // res7: Option[LocalDateTime] = Some(value = 2021-01-06T12:00)
Value of next elapse calculated by this library is different from the output of systemd-analyze calendar
command for the same input values. Example:
$ systemd-analyze calendar --iterations=1 "*-2-* 10:00:00"
Original form: *-2-* 10:00:00
Normalized form: *-02-* 10:00:00
Next elapse: Sat 2025-02-01 10:00:00 CET
(in UTC): Sat 2025-02-01 09:00:00 UTC
From now: 10 months 13 days left
$ date
Wed 20 Mar 2024 10:01:36 AM CET
$ sbt core/run --ref "2024-03-20T10:01:00" "*-2-* 10:00:00"
Normalized: *-02-* 10:00:00
Reference: 2024-03-20T10:01
Next Elapses:
- 2025-02-21T10:00
systemd returns 2025-02-01
and calev: 2025-02-21
. Is this difference intentional or is it a bug?
A Calendar instance contains calendar events (instances of CalEvent) each identified by a name (String).
case class ScheduledEvent(scheduledAt: ZonedDateTime, eventName: String, calendarEvent: CalEvent)
trait Calendar {
def calendarEvents: Map[String, CalEvent]
def upcomingEvent(ref: ZonedDateTme): Option[ScheduledEvent]
}
There could be different types of the calendar: DailyCalendar, WeeklyCalendar, MonthlyCalendar. The implementation of upcomingEvent method could be optimized for each calendar type.
To use this library from javascript, a scalajs build can be provided.
I misunderstood how ranges with repetitions work in systemd. See systemd/systemd#15030.
val cal = CalEvent.unsafe("Mon --* 15:00:00")
val calWithZone = cal.copy(zone = Some(ZoneOffset.UTC))
calWithZone.asString produces: Mon --* 15:00:00 Z
It should produce: Mon --* 15:00:00 UTC
@eikek Do you know what could be the reason the compilation of calev-core hangs ? I'm compiling only for jvm (not js).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.