Last change
on this file since 111 was
111,
checked in by jahn, 14 years ago
|
Committed as part of Event editing.
|
File size:
1.3 KB
|
Line | |
---|
1 | package dbnp.studycapturing |
---|
2 | |
---|
3 | import groovy.time.* |
---|
4 | |
---|
5 | /** |
---|
6 | * The Event class describes an actual event, as it has happened to a certain subject. Often, the same event occurs |
---|
7 | * to multiple subjects at the same time. That is why the actual description of the event is factored out into a more |
---|
8 | * general EventDescription class. Events that also lead to sample(s) should be instantiated as SamplingEvents. |
---|
9 | */ |
---|
10 | class Event { |
---|
11 | |
---|
12 | Subject subject |
---|
13 | EventDescription eventDescription |
---|
14 | Date startTime |
---|
15 | Date endTime |
---|
16 | |
---|
17 | |
---|
18 | // static constraints = { } |
---|
19 | def getDuration() { |
---|
20 | //endTime - startTime // this is not documented and does not work either |
---|
21 | // so, it's useless. |
---|
22 | // thus, do this manually as follows |
---|
23 | |
---|
24 | def timeMillis = (endTime.getTime() - startTime.getTime()).abs() |
---|
25 | def days = (timeMillis/(1000*60*60*24)).toInteger() |
---|
26 | def hours = (timeMillis/(1000*60*60)).toInteger() |
---|
27 | def minutes = (timeMillis/(1000*60)).toInteger() |
---|
28 | def seconds = (timeMillis/1000).toInteger() |
---|
29 | def millis = (timeMillis%1000).toInteger() |
---|
30 | |
---|
31 | return new Duration(days,hours,minutes,seconds,millis) |
---|
32 | } |
---|
33 | |
---|
34 | |
---|
35 | def getDurationString() |
---|
36 | { |
---|
37 | def d = getDuration() |
---|
38 | return "${d.days} days, ${d.hours} hrs, ${d.minutes} min, ${d.seconds} sec." |
---|
39 | } |
---|
40 | |
---|
41 | |
---|
42 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.