diff --git a/moment.cfc b/moment.cfc index 70bf469..ae34ee9 100755 --- a/moment.cfc +++ b/moment.cfc @@ -268,14 +268,14 @@ component displayname="moment" { return from( nnow ); } - public function epoch() hint="returns the number of milliseconds since 1/1/1970 (local)" { + public numeric function epoch() hint="returns the number of milliseconds since 1/1/1970 (local). Call .utc() first to get utc epoch" { /* It seems that we can't get CF to give us an actual UTC datetime object without using DateConvert(), which we can not rely on, because it depends on the system time being the local time converting from/to. Instead, we've devised a system of detecting the target time zone's offset and using it here (the only place it seems necessary) to return the expected epoch values. */ - return this.clone().getDateTime().getTime() - this.utc_conversion_offset; + return javacast("bigdecimal",this.clone().getDateTime().getTime() - this.utc_conversion_offset); } public function getDateTime() hint="return raw datetime object in current zone" { @@ -390,6 +390,10 @@ component displayname="moment" { return getTZ( this.zone ).inDayLightTime( dt ); } + public date function epochTimeToDate(epoch) { + return createObject( "java", "java.util.Date" ).init( javaCast( "long", epoch ) ); + } + //=========================================== //INTERNAL HELPERS //===========================================