Skip to content
Browse files

Consistent semicolons and spacing

  • Loading branch information...
1 parent cecf2a7 commit 33e1c90a22dd48c2b699d087fcf281e5cdd7e5ff @ecto committed Jun 28, 2012
Showing with 11 additions and 13 deletions.
  1. +11 −13 timeago.js
View
24 timeago.js
@@ -17,7 +17,7 @@
*
* Copyright (c) 2008-2011, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)
*/
-module.exports = function(timestamp) {
+module.exports = function (timestamp) {
if (timestamp instanceof Date) {
return inWords(timestamp);
} else if (typeof timestamp === "string") {
@@ -26,7 +26,6 @@ module.exports = function(timestamp) {
};
var settings = {
- refreshMillis: 60000,
allowFuture: false,
strings: {
prefixAgo: null,
@@ -46,14 +45,13 @@ var settings = {
years: "%d years",
numbers: []
}
-}
+};
var $l = settings.strings;
-module.exports.settings = settings
+module.exports.settings = settings;
$l.inWords = function (distanceMillis) {
-
var prefix = $l.prefixAgo;
var suffix = $l.suffixAgo;
if (settings.allowFuture) {
@@ -69,7 +67,7 @@ $l.inWords = function (distanceMillis) {
var days = hours / 24;
var years = days / 365;
- function substitute(stringOrFunction, number) {
+ function substitute (stringOrFunction, number) {
var string = typeof stringOrFunction === 'function' ? stringOrFunction(number, distanceMillis) : stringOrFunction;
var value = ($l.numbers && $l.numbers[number]) || number;
return string.replace(/%d/i, value);
@@ -88,24 +86,24 @@ $l.inWords = function (distanceMillis) {
substitute($l.years, Math.floor(years));
return [prefix, words, suffix].join(" ").toString().trim();
-}
+};
+
function parse (iso8601) {
- if (!iso8601) return
- var s = iso8601.trim()
+ if (!iso8601) return;
+ var s = iso8601.trim();
s = s.replace(/\.\d\d\d+/,""); // remove milliseconds
s = s.replace(/-/,"/").replace(/-/,"/");
s = s.replace(/T/," ").replace(/Z/," UTC");
s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
return new Date(s);
}
+$l.parse = parse;
-$l.parse = parse
-
-function inWords(date) {
+function inWords (date) {
return $l.inWords(distance(date));
}
-function distance(date) {
+function distance (date) {
return (new Date().getTime() - date.getTime());
}

0 comments on commit 33e1c90

Please sign in to comment.
Something went wrong with that request. Please try again.