GithubHelp home page GithubHelp logo

momentcfc's People

Contributors

artknight avatar atuttle avatar ryandeba avatar surgiie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

momentcfc's Issues

fromNow() errors out

invalid call of the function from, first Argument (compare) is of invalid type, can't cast Object type [DateTime] to a value of type [moment]

format() function with timezone

First of all, thanks for this cfc, I love moment.js and I am excited to see that functionality brought to cfml.

As it stands now, moment.cfc in the format() method will format for the current timezone of the server no matter what zone the moment has. (Easily seen by using a mask of 'long' or including the zone offset in the mask: 'zzzz').

Even if you are not interested in displaying the zone info in the formatted string, it could still be an issue, because of the times that are invalid due to the timezone (e.g. 2015-03-08 02:30AM in the America/New_York zone). If, for example, the server is not running on UTC but America/New_York, and maybe you don't care about this since the server ought to be on UTC :), then trying to convert 2015-03-07 09:30PM EST to UTC and outputting it will result in 2015-03-08 03:30AM, when it should be 2015-03-07 02:30AM.

weird format time bug in moment

<cfset date = new "/dailysandbox/cfc/lib/moment"("02/18/2016 12:10 PM")>
<cfdump var="#date.format("hh:mm tt")#" abort>

I get 12:02 PM and that is wrong.....

DST issue in UTCtoTZ() and TZtoUTC()

There's an issue when converting times from local to UTC and vice versa. The issue is when you get the offset, you get the offset based upon the current time stamp.

For example, if you were to UTCtoTZ("2015-02-01 05:00:00", "America/New_York"), you should get midnight. However, if you run the code today, the offset is going to be -4, instead of -5. This is because you're getting the current timestamp for the offset.

To resolve the problem, you need to feed the offset in the date/time of what you're converting.

Here's a sample of the logic I've used in the past when converting local to UTC:

// get the milliseconds from epoch of the supplied date/time
var ms = timezone.getOffset( javacast("long", dateDiff("s", createDateTime(1970, 1, 1, 0, 0, 0), arguments.time)) )*1000;

This would get the seconds from Epoch of the time that you supplied, so you're getting the correct offset based on the time you supplied.

Wording from fromNow() returns

Maybe its just me but the current return from the fromNow() method is somewhat confusing. If its less than 7 days will return Last Someday. This to me, can be a bit confusing say you had passed yesterdays date to the component it would return Last Wednesday which can be a bit confusing for some. Even though i think thats technically correct, some would think Last Wednesday as in 1 week ago Wednesday and not Yesterday. Would it be better to further check diff and return either yesterday or # days ago? And modify the weeks to return Last Someday or as it already is # weeks ago?

why multiple statements?

I just noticed this piece of code

public 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;
    var adjustment = (this.utc_conversion_offset > 0) ? -1 : 1;
    return this.clone().getDateTime().getTime();
    return this.clone().getDateTime().getTime() - (this.utc_conversion_offset * adjustment);
}

Only the first return will get executed! Why the other code?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.