Changeset 111

Show
Ignore:
Timestamp:
25-01-10 08:40:43 (4 years ago)
Author:
jahn
Message:

Committed as part of Event editing.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/domain/dbnp/studycapturing/Event.groovy

    r84 r111  
    11package dbnp.studycapturing 
     2 
     3import groovy.time.* 
    24 
    35/** 
     
    1315    Date endTime 
    1416 
    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) 
    1632    } 
    1733 
    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." 
    2039    } 
     40 
     41 
    2142}