/**
 *
 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
 *
 * 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, see <http://www.gnu.org/licenses/>.
 * 
 **/
/**
 * Implements the CFML Function dateconvert
 */
package lucee.runtime.functions.dateTime;

import lucee.runtime.PageContext;
import lucee.runtime.exp.ApplicationException;
import lucee.runtime.ext.function.Function;
import lucee.runtime.type.dt.DateTime;

public final class DateConvert implements Function {
	public static DateTime call(PageContext pc , String conversionType, DateTime date) throws ApplicationException {
		
		throw new ApplicationException("This function is no longer supported, because it gives you the wrong impression that the timezone is part of the date object, what is wrong!" +
				"When you wanna convert a Date to String based on the UTC timezone, do for example [DateTimeFormat(date:now(),timezone:'UTC')].");
		
		/*int offset = pc.getTimeZone().getOffset(date.getTime());
		conversionType=conversionType.toLowerCase();
		
		if(conversionType.equals("local2utc")) {
			return new DateTimeImpl(pc,date.getTime()-offset,false);
		}
		else if(conversionType.equals("utc2local")) {
			return new DateTimeImpl(pc,date.getTime()+offset,false);
		}		
		throw new ExpressionException("invalid conversion-type ["+conversionType+"] for function dateConvert");*/
	}
}
@@ -924,24 +924,68 @@
 nException;%0A
+import lucee.runtime.exp.FunctionException;%0A
 import lucee
@@ -1054,16 +1054,59 @@
 ateTime;
+%0Aimport lucee.runtime.type.dt.DateTimeImpl;
 %0A%0Apublic
@@ -1243,23 +1243,20 @@
  throws 
-Applica
+Func
 tionExce
@@ -1264,24 +1264,26 @@
 tion %7B%0A%09%09%0A%09%09
+//
 throw new Ap
@@ -1448,16 +1448,18 @@
 g!%22 +%0A%09%09
+//
 %09%09%22When 
@@ -1588,18 +1588,16 @@
 );%0A%09%09%0A%09%09
-/*
 int offs
@@ -1913,18 +1913,16 @@
 se);%0A%09%09%7D
-%09%09
 %0A%09%09throw
@@ -1930,15 +1930,13 @@
 new 
-Express
+Funct
 ionE
@@ -1944,16 +1944,52 @@
 ception(
+pc,%22DateConvert%22,1,%22conversionType%22,
 %22invalid
@@ -2053,15 +2053,13 @@
 nvert%22);
-*/
 %0A%09%7D%0A%7D

enable the function "DateConvert"