/* This file is part of the OdinMS Maple Story Server Copyright (C) 2008 ~ 2010 Patrick Huy <patrick.huy@frz.cc> Matthias Butz <matze@odinms.de> Jan Christian Meyer <vimes@odinms.de> This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation. You may not use, modify or distribute this program under any other version of the GNU Affero General Public License. This program 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ package tools; import java.util.Date; import java.util.SimpleTimeZone; import tools.packet.PacketHelper; /** * Provides a suite of tools for manipulating Korean Timestamps. * * @author Frz * @since Revision 746 * @version 1.0 */ public class KoreanDateUtil { private final static int ITEM_YEAR2000 = -1085019342; private final static long REAL_YEAR2000 = 946681229830l; /** * Converts a Unix Timestamp into File Time * * @param realTimestamp The actual timestamp in milliseconds. * @return A 64-bit long giving a filetime timestamp */ public static final long getTempBanTimestamp(final long realTimestamp) { // long time = (realTimestamp / 1000);//seconds return ((realTimestamp * 10000) + PacketHelper.FT_UT_OFFSET); } /** * Gets a timestamp for item expiration. * * @param realTimestamp The actual timestamp in milliseconds. * @return The Korean timestamp for the real timestamp. */ public static final int getItemTimestamp(final long realTimestamp) { final int time = (int) ((realTimestamp - REAL_YEAR2000) / 1000 / 60); // convert to minutes return (int) (time * 35.762787) + ITEM_YEAR2000; } public static boolean isDST() { return SimpleTimeZone.getDefault().inDaylightTime(new Date()); } public static long getFileTimestamp(long timeStampinMillis, boolean roundToMinutes) { if (isDST()) { timeStampinMillis -= 3600000L; } long time; if (roundToMinutes) { time = (timeStampinMillis / 1000 / 60) * 600000000; } else { time = timeStampinMillis * 10000; } return time + PacketHelper.FT_UT_OFFSET; } }