Changeset 167 for trunk/grails-app/domain
- Timestamp:
- Feb 3, 2010, 2:49:30 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/Event.groovy
r162 r167 24 24 ] 25 25 26 // static constraints = { }27 26 28 def getDuration() {29 27 // time diff between end and start date 30 28 // thus, do this manually as follows 31 29 def getDuration() { 32 30 def timeMillis = (endTime.getTime() - startTime.getTime()).abs() 33 31 def days = (timeMillis / (1000 * 60 * 60 * 24)).toInteger() … … 41 39 42 40 41 // return a string that prints the duration sensibly. 42 // the largest date unit (sec, min, h, day, week, month, or year) 43 // is output 43 44 def getPrettyDuration() { 44 // return a string that prints the duration sensibly. 45 // the largest date unit (sec, min, h, day, month, or year) 46 // is output 45 def duration = getDuration() 46 if( duration.getYears() > 0 ) return duration.getYears() + " years" 47 if( duration.getMonths() > 0 ) return duration.getMonths() + " months" 48 if( duration.getWeeks() > 0 ) return duration.getWeeks() + " weeks" 49 if( duration.getDays() > 0 ) return duration.getDays() + " days" 50 if( duration.getHours() > 0 ) return duration.getHours() + " minutes" 51 return duration.getSeconds() + " seconds" 47 52 } 48 53
Note: See TracChangeset
for help on using the changeset viewer.