-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
format() function with timezone #7
Comments
Hmm, as I live in America/New_York, maybe using it in a lot of my tests was not the best choice (because my system time will match)... I'll switch it up some and see what happens. I'll also try setting my system TZ to different zones and see what happens. Thanks for the report. |
I think the only way around this is going to be handling all of the formatting internally, only passing through to dateTimeFormat what we can rely on to get correct. If you could help define the unit tests that ensure every use-case is covered, it would be greatly appreciated. I'll get us started:
I've committed the above (build fails 😢 but this correctly shows the bug you've reported), and I'll continue to work on expanding the things that the tests cover as time permits. Feel free to send a pull request with additional expectations added here. |
Thanks for following up. You have basic issue covered in your test, I can look into adding some tests surrounding DST changes. I wanted to give some of the background of the DST issues I have had to see what you thought, but it got really long, so I won't mind if you don't read it 😄. The bottom line is I am not sure that The problem I have encountered is that I need ISO8601 UTC timestamps for interacting with an API (AWS), but I have a server set to the
On Railo/Lucee this will still output I realized that, at least for my purposes, I didn't need to add or subtract from my original date, what was at stake was a question of formatting the date using a given zone. so I could simply do this:
That will output This makes sense to me, because This shows, I think, that the zones matter when a datetime is parsed and created (string or
and http://www.luceedocs.org/function/parsedatetime
This makes me think that |
It took me a few days to come up with enough time, but I read it all. :) My impression of the problem and solution is that if we detect the time zone masks and do their rendering separately, allowing normal masking to fall through to dateTimeFormat, that should work.
|
Sorry if I am just repeating myself, but the problem I have had is that the formatting issues are not limited to outputting zones, how
That should output |
It does make sense, and thank you for continuing to try to beat this point into my head. :) Basically the solution I have in mind is that anything time zone related, including |
Entered #10 to address the misspelled mask |
Ha ha, sorry, I guess I have spent enough time on this that I needed to vent somewhere. So my argument was rather than figuring out every mask that will need correction, moment.cfc should just take advantage of the fact that the zone can be specified in I will stop browbeating you now 😄. |
Ah yes, I always forget that argument... I'm willing to give it a try, but we still need a comprehensive set of tests. 👍 |
@jcberquist I've been making an attempt at using this 3rd argument to So, with the code (
And the test:
I'm currently in UTC-5 (US/Central), and Hong Kong is UTC+8 (total difference of 13), and this is the test result:
The actual output is 13 hours ahead of expected; so I take this to mean that the Maybe instead of using |
Initial testing seems to indicate that this ( |
My understanding of the situation is as follows. When moment.cfc runs the |
Sure, that makes sense. Do you have any ideas on how we can deal with this problem? |
I think I've figured out a bug in my tests, and the latest changes (to be pushed) resolve this as far as I know. I'm not going to close this until you confirm that everything looks good to you! |
I took a look at this tonight; I cloned the repo and ran the tests. I have 8 fails here out of the 80 tests. I ran them on Lucee 4.5.1 with a system timezone of |
Hello, I was testing moment.cfc (great cfc!) and noticed format("iso8601") was not giving correct results. Two issues:
The updated code below fixes both issues; works for my "America/Los_Angeles" to "America/New_York" dates. Updated code (line 207): //return dateTimeFormat(this.time, 'yyyy-mm-dd') & 'T' & dateTimeFormat(this.time, 'HH:nn:ss') & 'Z';
return replace(dateTimeFormat( this.localTime, "yyyy-mm-dd'T'HH:nn:ssZ", this.zone ), "+0000", "Z"); FYI: DateTimeFormat() allows you to embed a single-quoted string in the mask just like Java. I don't know if this helps with the issues discussed here but it works for me. Again, great cfc! Thanks |
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 theformat()
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 butAmerica/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.The text was updated successfully, but these errors were encountered: