The Wayback Machine - https://web.archive.org/web/20201108165401/https://github.com/ng-bootstrap/ng-bootstrap/pull/3378
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

chore(datepicker): native date adapter defaults to midnight #3378

Open
wants to merge 1 commit into
base: master
from

Conversation

@peterblazejewicz
Copy link
Contributor

@peterblazejewicz peterblazejewicz commented Sep 23, 2019

This changes the default time hour computed by native date adapter to be
a midnight, which is default for default Date object when no hours are
set and aligns the behaviour with the UTC date adapter one.

The current behaviour (being changed by this PR), has been introduced without a comment here, changing the default Date object constructor defaulting to midnight, instead defaulting to noon:
83930cd#diff-9f982ce59e7ca1c194d2a43bd90a2e4fR13

Fixes: #3340

This changes the default time hour computed by native date adapter to be
a midnight, which is default for default Date object when no hours are
set and aligns the behaviour with the UTC date adapter one.
@codecov-io
Copy link

@codecov-io codecov-io commented Sep 24, 2019

Codecov Report

Merging #3378 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3378   +/-   ##
=======================================
  Coverage   90.88%   90.88%           
=======================================
  Files          95       95           
  Lines        2743     2743           
  Branches      510      510           
=======================================
  Hits         2493     2493           
  Misses        190      190           
  Partials       60       60
Flag Coverage Δ
#e2e 55.01% <0%> (ø) ⬆️
#unit 87.99% <100%> (ø) ⬆️
Impacted Files Coverage Δ
src/datepicker/adapters/ngb-date-native-adapter.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0186404...4b2e4cc. Read the comment docs.

@shyamal890
Copy link

@shyamal890 shyamal890 commented Sep 26, 2019

@maxokorokov can you please merge this change.

@maxokorokov
Copy link
Member

@maxokorokov maxokorokov commented Sep 27, 2019

Might be related to this → #1676, need to check in more details.

@peterblazejewicz
Copy link
Contributor Author

@peterblazejewicz peterblazejewicz commented Sep 27, 2019

@maxokorokov
Can you describe the steps required to repeat the problem?
#1615 (comment)
I've looked briefly into MD native date adapter on how to handle the hours (they default to midnight).

@maxokorokov
Copy link
Member

@maxokorokov maxokorokov commented Oct 3, 2019

@peterblazejewicz nope, not exactly, sorry. But it was something like resetting current timezone to Brazil.

@shyamal890
Copy link

@shyamal890 shyamal890 commented Oct 22, 2019

Guys if there is no underlying reason for this change why not revert back to the standard followed by most UI libraries?

Current flow seems like a hack. Moreover, which developer would want to have 12 pm as default, seems really odd.

@shyamal890
Copy link

@shyamal890 shyamal890 commented Nov 16, 2019

@maxokorokov Can you please include this in the upcoming datepicker updates.

@shyamal890
Copy link

@shyamal890 shyamal890 commented Dec 4, 2019

Can we have some clarity on whether this feature would be included or not?

@shyamal890
Copy link

@shyamal890 shyamal890 commented Dec 13, 2019

Kindly share an update on this pull request

@shyamal890
Copy link

@shyamal890 shyamal890 commented Dec 18, 2019

Dear Team, kindly merge this pull request to the master repo, or give an attribute through which this can be activated.

@maxokorokov maxokorokov added this to the 5.2.2 milestone Feb 7, 2020
@benouat
Copy link
Member

@benouat benouat commented Feb 7, 2020

@shyamal890 I can't tell you the details because I need to dig up into my memory... But for sure I can tell you (with more than 10 years of JS datepickers implementation expertise) that we must keep noon instead of midnight.

While I am performing the check in my memory, could you please explain me why you absolutely need it ?

@shyamal890
Copy link

@shyamal890 shyamal890 commented Feb 7, 2020

@benouat

  1. Most (Almost all) including Angular Material sets date to midnight instead of noon.
  2. In any type of date selection its expected by the end-user as well as the developer to have it at midnight (also eases saving to database). Having it automatically set to noon is an anti-pattern (Against the norm, developers have to be trained to add one more step to correct it)
@benouat
Copy link
Member

@benouat benouat commented Feb 7, 2020

@shyamal890 Thanks for your highlights!

I now remember one use case for example, leap second adjustment. If date model is set to midnight, it happens that you are changing day as compared to noon where you don't

And, yes, this is not made up example, I had this issue each single time, and as I told you I have some experience dealing with Javascript Framework ~10 years of various datepicker development)


Did you notice that the NgbDateNativeUTCAdapter is not messing around with the time part of the Date ? Maybe you could simply use that one ?

@maxokorokov maxokorokov removed this from the 5.2.2 milestone Feb 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants
You can’t perform that action at this time.