Skip to content
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

no implementation of amLocal #122

Closed
pantonis opened this issue Jan 29, 2017 · 17 comments
Closed

no implementation of amLocal #122

pantonis opened this issue Jan 29, 2017 · 17 comments

Comments

@pantonis
Copy link

Hi,

Is there any way to achieve what amLocal (angular-moment) does?

Thanks

@AlekBro
Copy link

AlekBro commented Mar 30, 2017

I also searching some method to convert from UTC to Local time, like it was in angular-moment:
{{message.date | amUtc | amLocal | amDateFormat:'MM.DD.YYYY HH:mm:ss'}}

Perhaps there is some other way to convert from UTC to Local time?

reberinformatik added a commit to reberinformatik/angular2-moment that referenced this issue May 8, 2017
@Hesesses
Copy link

This would be awesome! I would need to display amTimeAgo pipe in local time (not compared to utc time)

@urish
Copy link
Owner

urish commented Jun 23, 2017

A pull request will be appreciated!

@Hesesses
Copy link

@urish did you see this: reberinformatik@0d545cc

@urish
Copy link
Owner

urish commented Jun 26, 2017

Yes, if you can make a proper pull request out of it (with tests, updating the documentation in README and everything), that'd be awesome.

Here is an example for a good PR: https://github.com/urish/angular2-moment/pull/148/files

@benwilkins
Copy link
Contributor

@Hesesses @urish Any update on this? I need the same thing.

@urish
Copy link
Owner

urish commented Jul 12, 2017

No update from my end - if someone send a proper PR I will try to merge it this weekend

@benwilkins
Copy link
Contributor

10-4. Thanks for the update. I'll try to submit a PR this weekend if it hasn't already been submitted by then.

@Hesesses
Copy link

@benwilkins did you happen to be superhero and fixed this? :)

@benwilkins
Copy link
Contributor

@Hesesses Submitted PR: #153

The initial one had an incorrect file name causing the CI to fail. Just submitted an update for that, so hopefully will be merged soon.

@Hesesses
Copy link

Hesesses commented Jul 20, 2017

I updated the package, but still having problem to display the local time:

<p>{{notification.created_at}}</p> // "2017-07-20 15:05:22"
<p>{{notification.created_at  | amLocal | amDateFormat: 'YYYY-MM-DD HH:mm'}}</p>

I'm located UTC+3 and the bottom line should output "2017-07-20 18:05", but it displays the same UTC datetime as first row. Any ideas?

@Hesesses
Copy link

@benwilkins @urish should this work or not? :)

@alobban
Copy link

alobban commented Jul 28, 2017

amLocal pipe not working. getting error message below:

The pipe 'amLocal' could not be found

<td>{{ log.attributes.afn_time | amUtc | amLocal | amDateFormat: 'YYYY-MM-DD HH:mm' }}</td>

@sushilkg
Copy link

sushilkg commented Aug 1, 2017

I couldn't get the amLocal to working to convert from UTC to local - so I did it this way.

//in my component
this.dateBasedOnLocalTimeZone = new Date(this.comment.created_at + " UTC");

//in my template
{{ dateBasedOnLocalTimeZone | amTimeAgo }}

Reference: https://stackoverflow.com/a/6525602/651556

@benwilkins
Copy link
Contributor

Sorry. The PR I submitted was of someone else's code. I didn't test, just assumed he had. I may look into this more if I have time.

@benwilkins
Copy link
Contributor

benwilkins commented Aug 5, 2017

The conversion to local is done using moment(value).local(). In testing, if I start with a UTC date of 2017-08-06 20:30:00 and run {{ myDate | amUtc | amLocal | amDateFormat:'YYYY-MM-DD HH:mm }}, I still get the same time.

I tested a few different scenarios in the console to see what is happening. I'm GMT -0500, so I should be getting 2017-08-05 15:30:

moment(myDate).local().format('YYYY-MM-DD HH:mm') 
// Prints 2017-08-05 20:30

moment(myDate).utc().format('YYYY-MM-DD HH:mm') 
// Prints 2017-08-06 01:30

moment(myDate).utc().local().format('YYYY-MM-DD HH:mm') 
// Prints 2017-08-05 20:30

moment.utc(myDate).local().format('YYYY-MM-DD HH:mm') 
// Prints 2017-08-05 15:30 <= This one is correct!

It appears that the local pipe should first set the value as UTC, then convert it to local. I've submitted a PR with the update.

@urish - I actually need this fairly quickly. Could you review and update this weekend?

@urish
Copy link
Owner

urish commented Apr 17, 2018

Closing as we now have amLocal

@urish urish closed this as completed Apr 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants