tracker issue : CF-4129246

select a category, or use search below
(searches all categories and all time range)
Title:

ParseDateTime() ignores DST and converts time to standard time

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Richard Davies / Richard Davies (Richard Davies)

Created: 03/16/2016

Components: Language, Functions

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final /

Priority/Frequency: Major / Some users will encounter

Locale/System: English / Win All

Vote Count: 0

Listed in the version 2016.0.03.300466 Issues Fixed doc
Problem Description:

ParseDateTime() returns an incorrect value when converting timezones if the server is currently in daylight savings time.


Steps to Reproduce:

<cfoutput>
	<!--- My server is set to Pacific timezone (UTC-8) but DST is currently on so current timezone is PDT (UTC-7) --->
	<cfdump var="#GetTimezoneInfo()#">

	<!--- Since server is currently on PDT, this should return the exact same time (no timezone conversion),
		but it converts it to PST. --->
	<p>#ParseDateTime("3/15/2016 01:00:00 AM PDT")#</p>	<!--- Returns {ts '2016-03-15 00:00:00'} --->

	<!--- ParseDateTime() appears to ignore fact that DST is currently on and convert times to standard time, as
		verified by this test which shows no conversion for PST (despite server currently being on DST). --->
	<p>#ParseDateTime("3/15/2016 01:00:00 AM PST")#</p>	<!--- Returns {ts '2016-03-15 01:00:00'} --->
</cfoutput>


Actual Result:

ParseDateTime("3/15/2016 01:00:00 AM PDT") returns 12:00am when sever is on PDT.


Expected Result:

ParseDateTime("3/15/2016 01:00:00 AM PDT") should return 1:00am when sever is on PDT.


Any Workarounds:

None that I know of other than using GetTimezoneInfo().isDSTon to detect DST and manually add 1 hr to ParseDateTime() results with DateAdd().

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4129246

External Customer Info:
External Company:  
External Customer Name: Richard Davies
External Customer Email:  
External Test Config: My Hardware and Environment details:



Server Product 	ColdFusion

Version 	10,0,18,296330

Tomcat Version 	7.0.64.0

Edition 	Enterprise  

Operating System 	Windows Server 2012  

OS Version 	6.2  

Update Level 	/D:/Applications/CFusion/cfusion/lib/updates/chf10000018.jar  

Adobe Driver Version 	4.1 (Build 0001)  

Java Version 	1.7.0_15  

Java Vendor 	Oracle Corporation

Attachments:

  1. March 17, 2016 00:00:00: 1_ScreenClip.png

Comments:

The attached screen shot is the output of the code in Steps to Reproduce.
Comment by External U.
3278 | March 16, 2016 02:26:08 PM GMT
Richard, I am unable to observe the issue with a standalone installation of CF10u18 on Win 7x64. The test case: _tm = "3/15/2016 01:00:00 AM PDT"; writeOutput(getLocale() & "<br>"); sys_obj = createObject("java", "java.lang.System"); // store the existing JVM timeZone to reset it to the original value after this test is done. _org_tz = _tz = sys_obj.getProperty("user.timezone"); tzjava = CreateObject("java", "java.util.TimeZone"); writeOutput("sys time zone: " & _org_tz & "<br>"); writeoutput("parseDateTime(#_tm#): " & parseDateTime(_tm ,"MM/dd/yyyy HH:mm:ss") & "<br>"); writeOutput("is DST on: " & getTimeZoneInfo().isDSTOn); output: English (US) sys time zone: America/Los_Angeles parseDateTime(3/15/2016 01:00:00 AM PDT): {ts '2016-03-15 01:00:00'} is DST on: YES Can you pls share your output of the test case above. I'd like to know what you JVM system timezone is set to. Pls also confirm the update level of your CF10 server.
Comment by Piyush K.
3279 | April 05, 2016 07:09:14 AM GMT
The CF Administrator reports that the update level is update 18 (chf10000018.jar). Here is my output from your test case, which appears to be identical to your output: English (US) sys time zone: America/Los_Angeles parseDateTime(3/15/2016 01:00:00 AM PDT): {ts '2016-03-15 01:00:00'} is DST on: YES
Comment by External U.
3280 | April 05, 2016 10:43:06 AM GMT
I noticed that you're using a different set of parameters for parseDateTime than what I originally used. Here is a modified test case that better illustrates the issue: <cfscript> _tm = "3/15/2016 04:00:00 AM EDT"; writeOutput(getLocale() & "<br>"); sys_obj = createObject("java", "java.lang.System"); // store the existing JVM timeZone to reset it to the original value after this test is done. _org_tz = _tz = sys_obj.getProperty("user.timezone"); tzjava = CreateObject("java", "java.util.TimeZone"); writeOutput("sys time zone: " & _org_tz & "<br>"); writeoutput("parseDateTime(#_tm#): " & parseDateTime(_tm ,"MM/dd/yyyy HH:mm:ss") & "<br>"); writeoutput("parseDateTime(#_tm#): " & parseDateTime(_tm) & "<br>"); writeOutput("is DST on: " & getTimeZoneInfo().isDSTOn); </cfscript> Here's my output: English (US) sys time zone: America/Los_Angeles parseDateTime(3/15/2016 04:00:00 AM EDT): {ts '2016-03-15 04:00:00'} parseDateTime(3/15/2016 04:00:00 AM EDT): {ts '2016-03-15 00:00:00'} is DST on: YES You'll notice that with your format string, it just ignores the timezone completely. Without the format string, it converts 4 AM EDT into 12 AM, which is Pacific Standard Time. It should convert it to 1 AM (Pacific Daylight Time).
Comment by External U.
3281 | April 05, 2016 10:46:44 AM GMT
Any update on this issue?
Comment by External U.
3282 | May 03, 2016 10:19:56 AM GMT
Richard, The fix will be released in a future update. I'll share the change in the behavior post fix. The system time is set to Pacific Time. TEST CODE: _tm = "3/15/2016 01:00:00 AM PDT"; //dateFormat(now(), "MM/dd/yyyy ") & " " & timeFormat(now(), "hh:mm:ss 'PM' z"); // writeOutput("time #_tm#:" & dateTimeFormat(_tm, "EEE, d MMM yyyy HH:mm:ss zzz") & "<br>"); writeoutput("parseDateTime(#_tm#): " & parseDateTime(_tm, "MM/dd/yyyy HH:mm:ss") & "<br>"); writeoutput("parseDateTime(3/15/2016 01:00:00 AM PST): " & parseDateTime("3/15/2016 01:00:00 AM PST") & "<br>"); writeoutput("parseDateTime(#_tm#) - with no MASK: " & parseDateTime(_tm) & "<br>"); writeOutput("is DST on: " & getTimeZoneInfo().isDSTOn); writeOutput(getLocale() & "<br>"); OUTPUT: time 3/15/2016 01:00:00 AM PDT:Tue, 15 Mar 2016 01:03:00 PDT parseDateTime(3/15/2016 01:00:00 AM PDT): {ts '2016-03-15 01:00:00'} parseDateTime(3/15/2016 01:00:00 AM PST): {ts '2016-03-15 02:00:00'} parseDateTime(3/15/2016 01:00:00 AM PDT) - with no MASK: {ts '2016-03-15 01:00:00'} is DST on: YES English (US) sys time zone: America/Los_Angeles
Comment by Piyush K.
3283 | July 25, 2016 12:22:42 PM GMT