Graph designation (time ranges)

I have a code that needs to be done based on a schedule: for example. during working hours I do X, after hours Y. The schedule will be determined by our client, so I need a notation that people can write and analyze according to my program. I am thinking of something like:

12/25:0730-1730 Do Y [Mo-Fr]:0730-1730 Do X [Mo-Tu]:1730-0730 Do Y Fr:1730-Mo:0730 Do Y 

There will definitely be a weekly variation. Annual variation (holidays) seems likely. I would like the notation to be effective and flexible.

I also need Java code that will analyze time ranges and tell me which range the specified time is indicated in.

I searched the Internet and found nothing. The closest thing to it is CRON, which is not exactly what I need.

Does anyone know about the existing definition and implementation of notation?

Thanks,

+3
source share
2 answers

For Java, Joda time (Scala wrapper scala-time ) is a powerful library for calculating time. You can look at google-rfc-2445 , which does something like what you ask (?).

If you are looking for a Java planner http://www.quartz-scheduler.org/ , this is a good option.

+4
source

I don’t think you will find something out of the box. In such cases, it is better to implement the implementation yourself and fully control the code. You can use antlr to create a parser.

Add the concept of priority to your syntax. Then it will be easier to plan.

 01.01.2011-31.01.2011 prio 1 do-idle-stuff [Mo-Fr] prio 2 do-work [Sa-Su] prio 2 weekend 10.02.2011-17.02.2011 prio 3 go-on-holidays 
+1
source

Source: https://habr.com/ru/post/1346043/


All Articles