Comments (13)
Yes, only time ago at the moment. Contributions are always appreciated!
Are there any other pipes that you need?
from ngx-moment.
I guess I would need to know the intended scope of this package. If would this completely wrap around moment and use pipes for things like formatting or is it intended to be used for more edge case manipulations?
from ngx-moment.
Summarizing some of the leanings from angular-moment
, it seems like formatting and timezone related functions are also valuable.
I always like to see if a specific feature is valuable to some users before developing it, so user needs greatly shape the set of features in the library.
That's also why I asked whether there is something particular that you need...
from ngx-moment.
Formatting was the one I was looking for specifically.
from ngx-moment.
Something like {{myDate | amDateFormat:'MM.DD.YYYY HH:mm:ss'}
?
from ngx-moment.
Yea, that would work. This brings up interesting questions about the use of moment in angular. Would we be using the pipe system to generate moment objects that we then send into other moment pipes or would we simple use javascript native date objects and only use moment for display of the native date objects?
I am needing to take today's date and set it to the beginning of the day. This would be easy with a angular pip of {{myDate | amStartOf:'day'}}
but I would need the then start a counter every second to get the HH:mm:ss output I am looking for and then pass that into {{myMomentDate | amDateFormat:'HH:mm:ss}}
.
The alternative is to use js native date and just do:
var start = new Date();
start.setHours(0,0,0,0);
{{start | amDateFormat:'HH:mm:ss'}}
How do you envision moment being used within a more complex date oriented application?
from ngx-moment.
This is a good question. Based on my experience from angular-moment
, a set of composable pipes can make a lot of sense.
In general, we have 3 types of pipes there:
- Convert arbitrary value into a
moment()
. e.g. parsing a moment from a given string, likeamParse
does. - Manipulate an existing
moment()
object and return a new one, e.g. adding or subtracting time. - Converting a
moment()
to user readable format.amTimeAgo
,amDateFormat
andamCalendar
come into mind.
I think we can start by implementing amDateFormat
. In any case, all of the methods can supporting getting a native Date
object as input.
Thoughts?
from ngx-moment.
I am good with starting with just native Date
objects for the time being. Moving forward should we have all of the methods support both native Date
objects and Moment
objects or should we have specific methods for Moment
objects and different methods for Date
objects. Seems to me that amTimeAgo
should work off both Date
and Moment
objects.
from ngx-moment.
Yes, that makes sense to me. If you can help with contributing amDateFormat
(+ relevant unit tests) that will be awesome!
from ngx-moment.
I have already started on that and will do more tonight. Forgive my lack of experience, I am new to Angular 2. Can you only use Pipes from within the component template (HTML) or is it possible to use them from within the component class itself?
from ngx-moment.
Questions are always welcome :)
Pipes are intended to be used from template. Nothing is stopping you from creating an instance of the class directly within Javascript and call the methods (that's what we do in the unit-tests), though, in this case, you can simply call moment
methods directly inside your Component class - there is no need to go through the pipe. Does this make sense to you?
from ngx-moment.
Makes sense to me. Would we then need to import moment into any component that intends to use it? Moving further conversation of this into a gitter room for now unless you want to keep the log here. https://gitter.im/HeathNaylor/angular2-moment
from ngx-moment.
So we already have a amCalendar
pipe (#6) :-)
from ngx-moment.
Related Issues (20)
- amDateFormat does not refresh and and the browser is frozen
- Tslib missing from package.json file HOT 3
- amDuration set Humanize optionnal or create new pipe
- Check value emptiness in LocalTimePipe HOT 1
- Angular 8/9 HOT 1
- [docs] improve docs, how to import to core module HOT 1
- Support ng-add schematics HOT 1
- Setting relativeTimeThresholdOptions object doesn't work HOT 3
- Pipe could not be found with Angular 9 (Ivy enabled by default) HOT 7
- Problems with moment 2.25.0 HOT 16
- Getting warnings and errors related to moment and ngx-moment during compilation (ng serve) along with broken-page for timeago pipe HOT 1
- can't use amLocale with amLocal HOT 2
- ERROR Error: AddPipe: missing required arguments while using amAdd HOT 1
- ModuleWithProviders usage without type parameter no longer supported in angular 10. HOT 2
- Moment start with wrong time
- momentConstructor$a is not a function HOT 1
- i get warnings about pipes not being found despite importing everything HOT 2
- Errors since update to latest version (6.0.0) HOT 22
- Angular 13 + ngx-moment 6.0.2: This module is declared with using 'export = HOT 9
- amDateFormat - momentConstructor$9 is not a function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-moment.