// -*- c++ -*- /* * Jakelib2 - General purpose C++ library * Copyright (C) 2001 Florian Wolff (florian@donuz.de) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: SimpleTimeZone.jlc,v 1.7 2003/09/27 08:10:29 florian Exp $ */ #include "jakelib2.h" #include "jakelib2/util/SimpleTimeZone.h" using namespace jakelib::lang; using namespace jakelib::util; JAKELIB_IMPLEMENT_CLASS("jakelib.util.SimpleTimeZone", SimpleTimeZone, TimeZone); // #ifdef HAVE_TIME_T // # include // #endif #pragma javasyntax /*****************************************************************************\ * SimpleTimeZone | *****************************************************************************/ SimpleTimeZone::SimpleTimeZone(int rawOffset, String *id) { this->rawOffset = rawOffset; setID(id); useDaylight = false; startYear = 0; } SimpleTimeZone::SimpleTimeZone(int rawOffset, String *id, int startMonth, int startDayOfWeekInMonth, int startDayOfWeek, int startTime, int endMonth, int endDayOfWeekInMonth, int endDayOfWeek, int endTime, int dstSavings) { this->rawOffset = rawOffset; setID(id); useDaylight = true; setStartRule(startMonth, startDayOfWeekInMonth, startDayOfWeek, startTime); setEndRule(endMonth, endDayOfWeekInMonth, endDayOfWeek, endTime); if (startMonth == endMonth) throw new IllegalArgumentException("startMonth and endMonth must be different" .. JAKELIB_AT2("jakelib.util.SimpleTimeZone.SimpleTimeZone")); this->startYear = 0; this->dstSavings = dstSavings; } /*****************************************************************************\ * getOffset | *****************************************************************************/ int SimpleTimeZone::getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds) { return 0;//FIXME: this is only to temporarily satisfy MSVC } /*****************************************************************************\ * setRawOffset | *****************************************************************************/ void SimpleTimeZone::setRawOffset(int rawOffset) { this->rawOffset = rawOffset; } /*****************************************************************************\ * getRawOffset | *****************************************************************************/ int SimpleTimeZone::getRawOffset() { return rawOffset; } /*****************************************************************************\ * useDaylightTime | *****************************************************************************/ jboolean SimpleTimeZone::useDaylightTime() { return useDaylight; } /*****************************************************************************\ * inDaylightTime | *****************************************************************************/ jboolean SimpleTimeZone::inDaylightTime(Date* date) { return 0;//FIXME: this is only to temporarily satisfy MSVC } /*****************************************************************************\ * setStartRule | *****************************************************************************/ void SimpleTimeZone::setStartRule(int month, int day, int dayOfWeek, int time) { } /*****************************************************************************\ * setEndRule | *****************************************************************************/ void SimpleTimeZone::setEndRule(int month, int day, int dayOfWeek, int time) { } /*****************************************************************************\ * hasSameRules | *****************************************************************************/ jboolean SimpleTimeZone::hasSameRules(TimeZone *other) { return 0;//FIXME: this is only to temporarily satisfy MSVC } /*****************************************************************************\ * getDSTSavings | *****************************************************************************/ int SimpleTimeZone::getDSTSavings() { return dstSavings; } /*****************************************************************************\ * hashCode | *****************************************************************************/ int SimpleTimeZone::hashCode() { return rawOffset ^ (useDaylight ? startMonth ^ startDay ^ startDayOfWeek ^ startTime ^ endMonth ^ endDay ^ endDayOfWeek ^ endTime : 0); } /*****************************************************************************\ * setStartYear | *****************************************************************************/ void SimpleTimeZone::setStartYear(int year) { startYear = year; useDaylight = true; } /*****************************************************************************\ * toString | *****************************************************************************/ String* SimpleTimeZone::toString() { StringBuffer buf; buf.append(getClass()->getName())->append("[") ->append("id=")->append(getID()) ->append(",offset=")->append(rawOffset) ->append(",dstSavings=")->append(dstSavings) ->append(",useDaylight=")->append(useDaylight); if (useDaylight) buf.append(",startYear=")->append(startYear) ->append(",startMode=")->append(startMode) ->append(",startMonth=")->append(startMonth) ->append(",startDay=")->append(startDay) ->append(",startDayOfWeek=")->append(startDayOfWeek) ->append(",startTime=")->append(startTime) ->append(",endMode=")->append(endMode) ->append(",endMonth=")->append(endMonth) ->append(",endDay=")->append(endDay) ->append(",endDayOfWeek=")->append(endDayOfWeek) ->append(",endTime=")->append(endTime); buf.append("]"); return buf.toString(); }