Giter VIP home page Giter VIP logo

calev's Issues

Bug in readme

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)

Inconsistent output dates between calev-core and systemd cli

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
$ 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
  • main method from calev-core
$ 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?

Introduce Calendar API

A Calendar instance contains calendar events (instances of CalEvent) each identified by a name (String).

Calendar interface

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.

CalEvent.parse does not parse zone offsets

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.