angular-moment-picker
angular-moment-picker copied to clipboard
Round off on hours
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!
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
Hi @enkemari, I am not able to reproduce this issue, so could you please provide a full working example that shows this problem? Thanks
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()})
@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.
+1
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" />