Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 4986

Show
Ignore:
Timestamp:
07/19/08 18:42:17 (4 months ago)
Author:
bmamlin
Message:

logic-api-refactoring: Added HOURS to available Duration units

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/branches/logic-api-refactoring/src/api/org/openmrs/logic/Duration.java

    r4158 r4986  
    1818 * Represents a duration of time — e.g., one year, two weeks, or 18 months.  Used within criteria 
    1919 *  
     20 * @see org.openmrs.logic.LogicCriteria 
    2021 */ 
    2122public class Duration { 
    2223 
    2324    public static enum Units { 
    24         SECONDS, MINUTES, DAYS, WEEKS, MONTHS, YEARS 
     25        SECONDS, MINUTES, HOURS, DAYS, WEEKS, MONTHS, YEARS 
    2526    } 
    2627 
     
    5455        case MINUTES: 
    5556            return duration / 1440; 
     57        case HOURS: 
     58                return duration / 24; 
    5659        case DAYS: 
    5760            return duration; 
    5861        case WEEKS: 
    5962            return duration * 7; 
     63        case MONTHS: 
     64                return duration * 30; 
    6065        case YEARS: 
    6166            return duration * 365; 
     
    7883        case MINUTES: 
    7984            return d * 60000; 
     85        case HOURS: 
     86                return d * 3600000; 
    8087        case DAYS: 
    8188            return d * 86400000; 
     
    137144    /** 
    138145     *  
     146     * Returns a duration for the given number of hours 
     147     *  
     148     * @param duration number of hours for duration 
     149     * @return 
     150     */ 
     151    public static Duration hours(Double duration) { 
     152        return new Duration(duration, Units.HOURS); 
     153    } 
     154 
     155    /** 
     156     *  
     157     * Returns a duration for the given number of hours 
     158     *  
     159     * @param duration number of hours for duration 
     160     * @return 
     161     */ 
     162    public static Duration hours(int duration) { 
     163        return hours(new Double(duration)); 
     164    } 
     165 
     166    /** 
     167     *  
    139168     * Returns a duration for the given number of days 
    140169     *