asaglimbeni / django-datetime-widget

Bootstrap django-datetime-widget is a simple and clean widget for DateField, Timefiled and DateTimeField in Django framework. It is based on Bootstrap datetime picker, supports both Bootstrap 3 and Bootstrap 2
Other
219 stars 125 forks source link

How to hide current date information when using TimePicker? #63

Open bartoszhernas opened 9 years ago

bartoszhernas commented 9 years ago

I want to have only time picker, without date, but when using TimePicker, you can see date on the top

screenshot 2015-02-15 16 47 04

Is there any way to hide it?

BobBowles commented 9 years ago

I had the same problem, I don't live 2 centuries ago!

This is a workaround that works for me. It blanks the header of the popout. At least you don't see a ridiculous date! In your css file:

.datetimepicker th {
    visibility: hidden !important;
}

It leaves you with an empty header, probably with a bit more tweaking you can work round that in the css too.

symbiosdotwiki commented 8 years ago

Also having this issue. I'm not seeing how to differentiate the Date and Time pickers from the javascript to be able to avoid this.

symbiosdotwiki commented 8 years ago

After some digging,

widgets.py should be updated like so:

quoted_options = set([
    'format',
    'startDate',
    'endDate',
    'startView',
    'minView',
    'maxView',
    'todayBtn',
    'language',
    'pickerPosition',
    'viewSelect',
    'initialDate',
    'weekStart',
    'minuteStep'
    'daysOfWeekDisabled',
    'formatViewType'
    ])

and

class TimeWidget(PickerWidgetMixin, TimeInput):
    """
    TimeWidget is the corresponding widget for Time field, it renders only the time section of
    datetime picker.
    """

    format_name = 'TIME_INPUT_FORMATS'
    glyphicon = 'glyphicon-time'

    def __init__(self, attrs=None, options=None, usel10n=None, bootstrap_version=None):

        if options is None:
            options = {}

        # Set the default options to show only the timepicker object
        options['startView'] = options.get('startView', 1)
        options['minView'] = options.get('minView', 0)
        options['maxView'] = options.get('maxView', 1)
        options['format'] = options.get('format', 'hh:ii')
        options['formatViewType'] = 'time'

        super(TimeWidget, self).__init__(attrs, options, usel10n, bootstrap_version)