src/main/scala/net/tz/lift/util/DateExtension.scala
changeset 2 cf829ec742b3
equal deleted inserted replaced
1:69e26359f2c8 2:cf829ec742b3
       
     1 /*
       
     2  * Refactored from net.liftweb.util.TimeHelpers.scala, which is
       
     3  *
       
     4  * Copyright 2006-2011 WorldWide Conferencing, LLC and
       
     5  *
       
     6  * Licensed under the Apache License, Version 2.0 (the "License");
       
     7  * you may not use this file except in compliance with the License.
       
     8  * You may obtain a copy of the License at
       
     9  *
       
    10  *     http://www.apache.org/licenses/LICENSE-2.0
       
    11  *
       
    12  * Unless required by applicable law or agreed to in writing, software
       
    13  * distributed under the License is distributed on an "AS IS" BASIS,
       
    14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    15  * See the License for the specific language governing permissions and
       
    16  * limitations under the License.
       
    17  */
       
    18 package net.tz.lift.util
       
    19 
       
    20 import java.util.{Calendar, Date}
       
    21 
       
    22 /**
       
    23  * Fixed version of DateExtension (from
       
    24  * net.liftweb.util.TimeSpan.DateExtension).
       
    25  */
       
    26 class DateExtension(d: Date) {
       
    27   /** @returns a Date object starting at 00:00 from date */
       
    28   def noTime = {
       
    29     val calendar = Calendar.getInstance
       
    30     calendar.setTime(d)
       
    31     calendar.set(Calendar.HOUR_OF_DAY, 0)
       
    32     calendar.set(Calendar.MINUTE, 0)
       
    33     calendar.set(Calendar.SECOND, 0)
       
    34     calendar.set(Calendar.MILLISECOND, 0)
       
    35     calendar.getTime
       
    36   }
       
    37 }
       
    38 
       
    39 object DateExtension {
       
    40   implicit def date2dateExtension(d: Date): DateExtension =
       
    41     new DateExtension(d)
       
    42 }
       
    43 
       
    44 // vim: set ts=2 sw=2 et: