Sha256: a3a2451fd927cb9da8fde65639346a217ea9c1ed3224847bddd8bdc5906b83fd
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
'use strict'; angular.module('mgcrea.ngStrap.helpers.dateFormatter', []) .service('$dateFormatter', function($locale, dateFilter) { // The unused `lang` arguments are on purpose. The default implementation does not // use them and it always uses the locale loaded into the `$locale` service. // Custom implementations might use it, thus allowing different directives to // have different languages. this.getDefaultLocale = function() { return $locale.id; }; // Format is either a data format name, e.g. "shortTime" or "fullDate", or a date format // Return either the corresponding date format or the given date format. this.getDatetimeFormat = function(format, lang) { return $locale.DATETIME_FORMATS[format] || format; }; this.weekdaysShort = function(lang) { return $locale.DATETIME_FORMATS.SHORTDAY; }; function splitTimeFormat(format) { return /(h+)([:\.])?(m+)[ ]?(a?)/i.exec(format).slice(1); } // h:mm a => h this.hoursFormat = function(timeFormat) { return splitTimeFormat(timeFormat)[0]; }; // h:mm a => mm this.minutesFormat = function(timeFormat) { return splitTimeFormat(timeFormat)[2]; }; // h:mm a => : this.timeSeparator = function(timeFormat) { return splitTimeFormat(timeFormat)[1]; }; // h:mm a => true, H.mm => false this.showAM = function(timeFormat) { return !!splitTimeFormat(timeFormat)[3]; }; this.formatDate = function(date, format, lang){ return dateFilter(date, format); }; });
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails-angularstrap-2.2.0 | vendor/assets/javascripts/angular-strap/src/helpers/date-formatter.js |