
Company News
Socket Has Acquired Secure Annex
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.
xdan-datetimepicker-rails
Advanced tools
This gem adds @xdan's datetimepicker to the Rails asset pipeline.
Add this line to your application's Gemfile:
gem 'xdan-datetimepicker-rails'
And then execute:
$ bundle
Or install it yourself as:
$ gem install xdan-datetimepicker-rails
Require the jquery file into your application.js.coffee file:
#= require jquery.xdan.datetimepicker
Import the stylesheet in your application.css.scss file:
@import "jquery.xdan.datetimepicker";
Start using it!
# /app/assets/javascripts/datetimepicker.js.coffee
#= require jquery.xdan.datetimepicker
@setupDateTimePicker = (container) ->
defaults = {
formatDate: 'y-m-d',
format: 'Y-m-d H:i',
allowBlank: true,
defaultSelect: false,
validateOnBlur: false
}
entries = $(container).find('input.datetimepicker')
entries.each (index, entry) ->
options = $(entry).data 'datepicker-options'
$(entry).datetimepicker $.extend(defaults, options)
$ ->
setupDateTimePicker $('body')
See the detailed documentation for more options. When the site is back up I'll try to port some of them into this README or move them to the official repo of datetimepicker.
# /app/inputs/datetimepicker_input.rb
class DatetimepickerInput < SimpleForm::Inputs::StringInput
def input_html_classes
super.push("datetimepicker")
end
def input_type
:string
end
def input_html_options
super.tap do |opts|
opts[:data] ||= {}
opts[:data].merge! datepicker_options
opts[:value] ||= value
end
end
def value
val = object.send(attribute_name)
return DateTime.new(val.year, val.month, val.day, val.hour, val.min).strftime("%Y-%m-%d %H:%M") if val.is_a?(Time)
return val if val.nil?
val.to_s
end
private
def datepicker_options
options = self.options.fetch(:datepicker_options, {})
options = Hash[options.map{ |k, v| [k.to_s.camelcase(:lower), v] }]
{ datepicker_options: options }
end
end
# /app/inputs/datetimepicker_input.rb
class DatetimepickerInput < ::Formtastic::Inputs::StringInput
def input_html_options
super.tap do |options|
options[:class] = [options[:class], "datetimepicker"].compact.join(' ')
options[:data] ||= {}
options[:data].merge! datepicker_options
options[:value] ||= value
end
end
def value
val = object.send(method)
return DateTime.new(val.year, val.month, val.day, val.hour, val.min).strftime("%Y-%m-%d %H:%M") if val.is_a?(Time)
return val if val.nil?
val.to_s
end
private
def datepicker_options
options = self.options.fetch(:datepicker_options, {})
options = Hash[options.map{ |k, v| [k.to_s.camelcase(:lower), v] }]
{ datepicker_options: options }
end
end
This gem will attempt to maintain the same version as the datetimepicker library.
git checkout -b my-new-feature)git commit -am 'Add some feature')git push origin my-new-feature)FAQs
Unknown package
We found that xdan-datetimepicker-rails demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.

Research
/Security News
Socket is tracking cloned Open VSX extensions tied to GlassWorm, with several updated from benign-looking sleepers into malware delivery vehicles.

Product
Reachability analysis for PHP is now available in experimental, helping teams identify which vulnerabilities are actually exploitable.