Sha256: f44691985ab96476f382c834215219087db18e18c8bac4808fa7eb1938cc4abe
Contents?: true
Size: 815 Bytes
Versions: 4
Compression:
Stored size: 815 Bytes
Contents
(function(ko, $, moment) { "use strict"; ko.extenders.date = function(target, options) { options = options || { internal: 'YYYY-MM-DD', external: 'YYYY-MM-DD' }; options.external = options.external || options.internal; target.date = ko.computed({ read: function() { var m = moment(target(), options.internal); return m && m.isValid() ? m.format(options.external) : null; }, write: function(newValue) { var m = moment(newValue, options.external), formatted = m && m.isValid() ? m.format(options.internal) : newValue; target(formatted); } }, this); //return the original observable return target; }; })(ko, $, moment);
Version data entries
4 entries across 4 versions & 1 rubygems