Changeset 111
- Timestamp:
- Jan 25, 2010, 8:40:43 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/Event.groovy
r84 r111 1 1 package dbnp.studycapturing 2 3 import groovy.time.* 2 4 3 5 /** … … 13 15 Date endTime 14 16 15 static constraints = { 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) 16 32 } 17 33 18 def getDuration() { 19 endTime - startTime 34 35 def getDurationString() 36 { 37 def d = getDuration() 38 return "${d.days} days, ${d.hours} hrs, ${d.minutes} min, ${d.seconds} sec." 20 39 } 40 41 21 42 }
Note: See TracChangeset
for help on using the changeset viewer.