Description
One of the packable projects #140.
org.csstudio.apputil.time currently offers routines for formatting and parsing time stamps as both absolute ("2007/06/01 14:00:24.156959772") and relative time ("-2 Months +5 years"), which is mostly used for time ranges ("-2 weeks" until "now") in the Data Browser, alarm msg history.
I believe other plugins (logbook viewer?) introduced similar code for specifying times
This needs to be consolidated that with org.epics.util.time.Timestamp and TimeInterval.
It might be a good idea to wait for Java 8 and its java.time.Instant, Duration, Period.
On the other hand we already have related issues like #136 that require tweaks to the existing code, so maybe it's OK to start this now based on a Java 8 backport for JSR 310: http://threeten.github.io/
However it is eventually implemented, requirements include:
Absolute time stamps:
Allow users to enter them directly, and via a 'calendar' type GUI. Time stamps need to be written to XML config files, parsed from them, displayed in the GUI, parsed from user-entered text fields etc. in one format. A format yyyy/MM/dd HH:mm:ss.SSS would be good for compatibility with existing code, and also because it sorts "alphabetically". If the new time stamp support can recognize additional formats, that's nice, but not sure if that is essential.
Relative time stamps:
Configuration files, direct entry by user as text, a GUI that may for example offer 'up/down' selectors all need to support relative time range specifications. Exact format TBD, but conceptually it needs to support "last 2 weeks until now", "last 8 hours until now", "3 months ago until 2 weeks ago".
That relative time should not internally simply convert into seconds. For example, it should allow "the last month". When invoked in February, that means "January 1st until (including) January 31st". When that same "last month" is instead evaluated on March 2nd, it needs to evaluate into "February 1 until Feb. 28" (or Feb. 29 for leap years). Similarly, it would be really nice to be able to express "previous shift", which means the last 06:00 - 18:00 or 18:00 - 06:00 period.
This allows control room operators or operations managers to generate periodic reports by simply opening a data browser config for "last month" and saving the screenshot instead of having to manually adjust the time range to the exact start/end of the last reporting period.