diff -r 69e26359f2c8 -r cf829ec742b3 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 Sun Apr 03 15:55:02 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: