# HG changeset patch # User Tomas Zeman # Date 1301396906 -7200 # Node ID 05d8eaf4c78b577487cf305a04261cd93a00f86d # Parent c500a54abf33b2bb637192d92a5fb2ab6765d640 DateExtension fix diff -r c500a54abf33 -r 05d8eaf4c78b src/main/scala/net/tz/lift/util/DateExtension.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/scala/net/tz/lift/util/DateExtension.scala Tue Mar 29 13:08:26 2011 +0200 @@ -0,0 +1,44 @@ +/* + * Refactored from net.liftweb.util.TimeHelpers.scala, which is + * + * Copyright 2006-2011 WorldWide Conferencing, LLC and + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.tz.lift.util + +import java.util.{Calendar, Date} + +/** + * Fixed version of DateExtension (from + * net.liftweb.util.TimeSpan.DateExtension). + */ +class DateExtension(d: Date) { + /** @returns a Date object starting at 00:00 from date */ + def noTime = { + val calendar = Calendar.getInstance + calendar.setTime(d) + calendar.set(Calendar.HOUR_OF_DAY, 0) + calendar.set(Calendar.MINUTE, 0) + calendar.set(Calendar.SECOND, 0) + calendar.set(Calendar.MILLISECOND, 0) + calendar.getTime + } +} + +object DateExtension { + implicit def date2dateExtension(d: Date): DateExtension = + new DateExtension(d) +} + +// vim: set ts=2 sw=2 et: