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

Back to 1899 #83

Open
pisapapiros opened this issue Oct 8, 2015 · 7 comments
Open

Back to 1899 #83

pisapapiros opened this issue Oct 8, 2015 · 7 comments

Comments

@pisapapiros
Copy link

Hello,

I've been working with this widget for a while and I found it very useful for my project.

When it comes to fill a new datetime field everything is ok. However, attempting to open the widget for edition, it jumps back to 1899. It works, but I want to launch it from the date shown in the field.

image

My widget settings:
dateTimeOptions = {
'format': 'dd.mm.yyyy hh:00', # I guess this is causing the problem
'autoclose': True,
'todayHighlight': True,
'minuteStep': 60,
'minView': 1,
'maxView': 2
}

I've tried to access to the widget from js, but I couldn't. Is it possible?

Thanks in advance

@michaeljones
Copy link
Contributor

Hi, are you using localisation (the l10n option)? That can cause some issues as it overrides the date format.

@pisapapiros
Copy link
Author

Hello michaeljones,

I'm not using it. This is my config:
widgets =
{
'date': DateTimeWidget(attrs={}, options=dateTimeOptions, bootstrap_version=3)
}

Actually if I add "usel10n = True" the plugin doen't start from 1899, but my datetime format gets overwritten.

@pisapapiros
Copy link
Author

Is there a way to reference the existing datepicker? like: $dateField.datepicker().

Or maybe implementing a callback after certain datepicker functions are executed? eg. after hiding it.

This would let me fix my issues :)

@michaeljones
Copy link
Contributor

I'm not sure myself. I'd have to look into it further. Can I ask, does it behave better if you have dd.mm.yyyy hh:ii for the format? Or yyyy-mm-dd hh:ii? Which is what I have. That seems to work for me. I'm not saying you should use that but it would be interesting to know if it works.

@pisapapiros
Copy link
Author

Sure you can ask! that format works perfect. The point is the user should only set the date and the hour, but always leave minutes and seconds to 0. That's way I use the format dd.mm.yyyy hh:00 instead of dd.mm.yyyy hh:ii, and use the options 'minView': 1,'maxView': 2.

Although if the form field is empty it does work, when it comes to editing an already saved datetime the widget must got broken or something and it opens the calendar in 1899. Initializing the widget with my custom format seems quite hard to handle for the module.

Am I missing a more effective way of fixing the minutes to 0?

@shaunagm
Copy link

@pisapapiros Did you ever find a fix for this? I'm also having this issue.

@MSISM
Copy link

MSISM commented Feb 12, 2018

Well, I have the same problem.

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

No branches or pull requests

4 participants