This now seems to be along the correct lines  - the issue I had was a 
styling conflict with calendar.css file in web2py for the hour class being 
set to 2em and my hack for now to fix was to append the following to the 
std datetimepicker.css that can  be downloaded however not sure if there is 
a better way.

/* To revernt font 2em in web2py calendar component */
.hour, .minute {font-size: 14px;}




On Wednesday, July 6, 2016 at 1:17:59 PM UTC+1, Donald McClymont wrote:
>
> This is nice and a great improvement for dates.  I thought I could easily 
> replicate for datetime by using this which seems to be a fork of the 
> original to allow time input as well
>
>
> http://www.malot.fr/bootstrap-datetimepicker/demo.php?utm_source=siteweb&utm_medium=demo&utm_campaign=Site%2BWeb
>
> https://github.com/smalot/bootstrap-datetimepicker
>
> however it seems to not be formatting the time selection correctly for 
> some reason and may well need some adjustment to update with the script.  I 
> will continue to look at getting working but if anyone else can provide 
> some hints on how to do this then would be good to have both options 
> available in some manner.
>
> Donald
>
>
> On Tuesday, July 5, 2016 at 5:10:44 PM UTC+1, Ron Chatterjee wrote:
>>
>> I had my fair share of evaluation. Which looks better?
>>
>>
>>
>> On Monday, May 11, 2015 at 5:01:36 PM UTC-4, villas wrote:
>>>
>>> Thanks Leonel.
>>>
>>> BTW in your first post you said:   
>>>     Field('birthdate', 'date', widget=bsdatepicker_widget) 
>>>
>>> It should be with brackets at the end:
>>>     Field('birthdate', 'date', widget=bsdatepicker_widget()) 
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
# -*- coding: utf-8 -*-
"""
Integrates bootstrap-datepicker nicely into web2py.
"""

__author__ = 'Leonel Câmara'
__email__ = 'leonel.cam...@i-am.pt leonelcam...@gmail.com'
__copyright__ = 'Copyright(c) 2014 Leonel Câmara'
__license__ = 'BEER-WARE'
__version__ = '0.11'
__status__ = 'Development'  # possible options: Prototype, Development, Production


from gluon import *
from gluon.sqlhtml import FormWidget



def bsdatepicker_widget(**settings):
    """
    Usage:
    
    from plugin_bs_datepicker import bsdatepicker_widget
    db.table.field.widget = bsdatepicker_widget()

    Another example:

    db.table.field.widget = bsdatepicker_widget(startView=2)

    Possible settings:
    weekStart -- defaults to 0, day of the week start. 0 for Sunday - 6 for Saturday
    startView  -- defaults to  0 = 'days'  set the start view mode. Accepts: 'days', 'months', 'years', 0 for days, 1 for months and 2 for years.
    minViewMode -- defaults to 0 = 'days'  set a limit for view mode. Accepts: 'days', 'months', 'years', 0 for days, 1 for months and 2 for years.
    """

    def widget(field, value, **attributes):
        default = {'value': value}
        
        attributes = FormWidget._attributes(field, default, **attributes)
        attributes['_class'] = 'form-control datepicker'
                    
        dateinput = INPUT(**attributes)
        settings_str = ',\n'.join(item[0] + ':' + str(item[1]) for item in settings.iteritems()) if settings else ''
        javascript = SCRIPT("""
            $('head').append($('<link  href="%(cssurl)s" type="text/css" rel="stylesheet" />'));
            $.getScript('%(scripturl)s').done(function(){
                $('#%(_id)s').datepicker({
                    format: w2p_ajax_date_format.replace('%%Y', 'yyyy').replace('%%m', 'mm').replace('%%d', 'dd'),
                    %(settings)s
                })
            });
            """ % {
                'cssurl': URL('static', 'plugin_bs_datepicker/datepicker.css'),
                'scripturl': URL('static', 'plugin_bs_datepicker/bootstrap-datepicker.js'),
                '_id': dateinput.attributes['_id'],
                'settings': settings_str
            })
        return CAT(dateinput, javascript)

    return widget

    
def bsdatetimepicker_widget(**settings):
    """
    Usage:
    
    from plugin_bs_datepicker import bsdatepicker_widget
    db.table.field.widget = bsdatepicker_widget()

    Another example:

    db.table.field.widget = bsdatepicker_widget(startView=2)

    Possible settings:
    weekStart -- defaults to 0, day of the week start. 0 for Sunday - 6 for Saturday
    startView  -- defaults to  0 = 'days'  set the start view mode. Accepts: 'days', 'months', 'years', 0 for days, 1 for months and 2 for years.
    minViewMode -- defaults to 0 = 'days'  set a limit for view mode. Accepts: 'days', 'months', 'years', 0 for days, 1 for months and 2 for years.
    """

    def widget(field, value, **attributes):
        default = {'value': value}
        
        attributes = FormWidget._attributes(field, default, **attributes)
        #attributes['_class'] = 'form-control input-append date form_datetime'
        attributes['_class'] = 'form-control form_datetime'
                    
        dateinput = INPUT(**attributes)
        settings_str = ',\n'.join(item[0] + ':' + str(item[1]) for item in settings.iteritems()) if settings else ''
        javascript = SCRIPT("""
            $('head').append($('<link  href="%(cssurl)s" type="text/css" rel="stylesheet" />'));
            $.getScript('%(scripturl)s').done(function(){
                $('#%(_id)s').datetimepicker({
                    format: w2p_ajax_datetime_format.replace('%%Y', 'yyyy').replace('%%m', 'mm').replace('%%d', 'dd').replace('%%H', 'hh').replace('%%M', 'ii').replace('%%S', '00'),
                    %(settings)s
                })
            });
            """ % {
                'cssurl': URL('static', 'plugin_bs_datepicker/bootstrap-datetimepicker.css'),
                'scripturl': URL('static', 'plugin_bs_datepicker/bootstrap-datetimepicker.js'),
                '_id': dateinput.attributes['_id'],
                'settings': settings_str
            })
        return CAT(dateinput, javascript)

    return widget

Reply via email to