Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove dependency to String in Date (loose coupling)

  • Loading branch information...
commit 6987dd5d6d7f21d435c32e927cac4134ac404004 1 parent bd307d8
@jpolo authored
Showing with 13 additions and 4 deletions.
  1. +13 −4 Date.js
View
17 Date.js
@@ -1,17 +1,26 @@
/*jslint indent:2 */
/*global define, global, module_, use_, def_, keyword_, trait_, class_, mixin_ */
-define("stj/Date", [ "stj/module", "stj/class", "stj/String" ], function () {
+define("stj/Date", [ "stj/module", "stj/class" ], function () {
"use strict";
class_("DateFormatter", Object, function ($class) {
var
stringify = String,
- pad = function (value, length) {
- return stringify(value).pad(length || 2, "0", "l");
- },
round = Math.round,
floor = Math.floor,
abs = Math.abs,
+ min = Math.min,
+ pad = function pad(value, length) {
+ var
+ chars = "0",
+ result = stringify(value),
+ count = (length || 2) - result.length;
+ while (count > 0) {
+ result = chars + result;
+ count -= 1;
+ }
+ return result;
+ },
DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
MONTHS = [null, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
REGEXP_TIMEZONE = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[\-+]\d{4})?)\b/g,
Please sign in to comment.
Something went wrong with that request. Please try again.