angular-moment-picker icon indicating copy to clipboard operation
angular-moment-picker copied to clipboard

Round off on hours

Open enkemari opened this issue 7 years ago • 6 comments

Hi,

[This might sound a bit pedantic...] I've got a requirement where I have to limit the picker to hours - which is easy to do with max-view="day" - however, I also use today="true" and when the current time is anything other than HH:00, the minutes are pulled through to the display (not sure if today="true" is necessarily causing this).

So the scenario is that the user would select the date, then the hour as e.g. 12:00 and then nothing else, but because it's now 10:07, the display will indicate that they selected 12:07, which is not true and will obscure the results retrieve for e.g. reporting workspaces.

I hope that makes sense.

So what I'm asking is if I'm missing any setting that would limit the hours displayed to flat hours when max-view="day"?

Thanks for a great product, by the way - it's our go-to!

enkemari avatar Apr 24 '17 08:04 enkemari

Hi !

I add the same problem some weeks ago. I used this turnaround

placeholder="01 October 2042"

I just hard coded the fact that I wanted the first day of the month in the placeholder and that made the trick.

Hope it helps

Matthieu

clinm avatar Apr 25 '17 10:04 clinm

Hi @enkemari, I am not able to reproduce this issue, so could you please provide a full working example that shows this problem? Thanks

indrimuska avatar May 07 '17 10:05 indrimuska

I have the same issue. The problem is in moment() constructor, which defaults to current time. I've replaced all moment constructors with no argument with moment('2001-01-01'). That seems to solve the problem.

EDIT: This should be a better solution: moment({ year: new Date().getFullYear()})

vkrizan avatar Aug 28 '17 12:08 vkrizan

@indrimuska This is easily observed when set-on-select="true" for format YYYY-MM-DD HH:mm. When you select the month, you can see that day, hour and minutes (seconds) have been already set to current time, rather than defaulting to 1 for months and days, and 00 for hours, minutes and seconds.

vkrizan avatar Aug 28 '17 12:08 vkrizan

+1

jacksonrdlc avatar Nov 21 '17 16:11 jacksonrdlc

I solved this way

<input ...
   id="time"
   moment-picker="form.input_time"
   ng-model="form.input_time"
   ng-model-options="{ updateOn: 'blur' }"
   format="LT"
   min-view="day"
   max-view="hour"
   today="false"
   show-header="false" />

heavyrick avatar May 21 '18 21:05 heavyrick