Just messing around with it, but this works fine. It's probably a little
unnecessary to go about the whole createDate bit, but it works and the
results from the output are what you expect.
--Ferg
<cffunction name="GetNISTTime" returntype="struct" output="false">
<cfset var timeServer="192.43.244.18">
<cfset var result=StructNew()>
*<!--- Try/catch block --->*
<cftry>
*<!--- Try get time data --->*
<cfhttp url="http://#timeServer#:13/" />
*<!--- Save raw data --->*
<cfset result.raw = CFHTTP.FileContent>
*<!--- Extract Julian date --->*
<cfset result.julian=ListGetAt(result.raw, 1, " ")>
*<!--- Extract current date and time --->*
<cfset result.Date =
dateFormat(createDate(listGetAt(ListGetAt(result.raw, 2, " "),1, "-"),
listGetAt(ListGetAt(result.raw, 2, " "),2, "-"),
listGetAt(ListGetAt(result.raw, 2, " "),3, "-")),"d/m/yyyy")>
<cfset result.Time = ListGetAt(result.raw, 3, " ")>
<cfset result.now=ParseDateTime(result.Date &" "& result.Time)>
*<!--- Extract daylight savings time flag --->*
<cfset result.dst=IIf(ListGetAt(result.raw, 4, " ") IS 0, FALSE,
TRUE)>
*<!--- Extract leap month flag --->*
<cfset result.leapmonth=IIf(ListGetAt(result.raw, 5, " ") IS 0,
FALSE, TRUE)>
*<!--- Extract health flag --->*
<cfset result.healthy=IIf(ListGetAt(result.raw, 6, " ") IS 0,
FALSE, TRUE)>
*<!--- Extract advance milliseconds --->*
<cfset result.msadv=ListGetAt(result.raw, 7, " ")>
*<!--- Success --->*
<cfset result.success=TRUE>
*<!--- Catch any errors --->*
<cfcatch type="any">
<cfset result.success=FALSE>
</cfcatch>
</cftry>
<cfreturn result>
</cffunction>
<cfdump var="#GetNISTTime()#">
<cfoutput>
#GetNISTTime().now#<br />
#dateFormat(GetNISTTime().now, "d/m/yyyy")#<br />
</cfoutput>
Ken Ferguson wrote:
> struct
> DST TRUE
> HEALTHY FALSE
> JULIAN 53880
> LEAPMONTH FALSE
> MSADV 87.0
> NOW {ts '2025-06-05 13:24:49'}
> RAW 53880 06-05-25 13:24:49 50 0 0 87.0 UTC(NIST) *
> SUCCESS TRUE
>
>
>
> Here's what I get when I run your code. You'll see that NOW is getting
> all horqued up!
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:241443
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54