Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Break up timepicker's model into separate values #5957

Open
wesleycho opened this issue Jun 3, 2016 · 10 comments
Open

Break up timepicker's model into separate values #5957

wesleycho opened this issue Jun 3, 2016 · 10 comments

Comments

@wesleycho
Copy link
Contributor

This change is to break up the model into separate values, i.e. hours, minutes, and seconds. This is to fix date related issues for a component that shouldn't rely on date objects at all.

@pkozlowski-opensource
Copy link
Member

@wesleycho since I'm looking into timepicker in the context of https://github.com/ng-bootstrap/ng-bootstrap I would like to brainstorm here.

I totally agree that using Date object is sub-optimal and we should use another data structure instead. What is your current thinking regarding the exact data structure? For me it could one of:

  • string (possibly with a configurable parsing / formatting strategy)
  • A predefined data structure (ex. {hour: 12, minute: 15: second: 00})
  • any arbitrary data structure where a user is obliged to provide parsing / formatting utility

At the end of the day we want sth like: <input ng-model="timeExp" bs-timepicker> and we need to define:

  • allowed values for timeExp
  • how to turn value of timeExp to a string (we need it so we can display a selected time in the input field)

Thought?

@wesleycho
Copy link
Contributor Author

I'm a fan of using an object (second option), that way it is a nice & expected structure, and simple enough for a user to work with (i.e. modifying a date object with the time values to submit to a server).

Allowed values - we should validate that the object is explicitly as we expect (predefined data structure).
Converting to string - given predefined structure, would be very easy to convert to string for each input using a leftPad function.

@pkozlowski-opensource
Copy link
Member

I'm a fan of using an object (second option), that way it is a nice & expected structure, and simple enough for a user to work with

I agree. Let's start with this. We could always add more formats as we go.

@sendilkumarn
Copy link

I too agree we could use the object. I think it is more flexible.

@icfantv
Copy link
Contributor

icfantv commented Jul 19, 2016

specific Issues (individually closed) to address in rewrite:

  • form validation
    • manually clearing fields
    • when min/max is used
    • ng-required support
    • support 0 values
    • investigate supporting dynamic values for min and max
  • when used in modal
  • ng-model-options support
  • do not use Date as model object (store fields separately)
  • investigate use from within input-group-btn (may be CSS issue on user side)

@alcalbg
Copy link

alcalbg commented Oct 4, 2016

I am looking to rewrite my time tracking utility with ng. At the moment I have time and date tied together so when you push time back beyond 'zero' date will update accordingly to day before. In other words script will update date values if you're pushing time over date boundaries.

For me it is very useful to have this two tied together (time and date) because I think this is more natural behavior for this type of objects.

I don't have a plunker here but you can try this on my demo 'Add Time Entry' button.

@icfantv
Copy link
Contributor

icfantv commented Oct 4, 2016

@alcalbg this is something you would best manage yourself and it's not that hard. Using the same Date object for both the date and time picker is fraught with gotchas and corner cases which is why we do not support it.

@wesleycho wesleycho modified the milestones: Backlog, 3.0.0 Oct 11, 2016
@pjohnmeyer
Copy link
Contributor

I do second the notion of using an object for the input per my thumbs-up above. I will suggest, though, that the object should continue to use a defined subset of JS Date standard getters & setters instead of direct member access, so that a Date object or Date object proxy can be easily used. Or, introduce your own proxy object interface with a pre-built wrapper for Date. Date certainly has its problems, but it still handles a lot of bad cases for us that I don't want to have to deal with.

@philipp-serfling
Copy link

Is there any eta? This bug is making me trouble 6088

@fa-hmad
Copy link

fa-hmad commented Apr 27, 2018

Any status on this? Relying on the Date object is definitely suboptimal.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants