From e3533cccee4ee7cca769de410628fcdf9069ee8a Mon Sep 17 00:00:00 2001
From: Ryan McGeary
Date: Sun, 25 Jan 2009 18:53:26 -0500
Subject: [PATCH 01/16] Copyright 2008-2009
---
README.markdown | 2 +-
index.html | 2 +-
jquery.timeago.js | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.markdown b/README.markdown
index e795fd37..dc06ac45 100644
--- a/README.markdown
+++ b/README.markdown
@@ -37,4 +37,4 @@ As time passes, the timestamps will automatically update.
[MIT License](http://www.opensource.org/licenses/mit-license.php)
-Copyright (c) 2008, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)
+Copyright (c) 2008-2009, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)
diff --git a/index.html b/index.html
index 26c085bf..0b7ebc45 100644
--- a/index.html
+++ b/index.html
@@ -159,7 +159,7 @@ Huh?
MIT
License
- Copyright © 2008 Ryan McGeary
+ Copyright © 2008-2009 Ryan McGeary
diff --git a/jquery.timeago.js b/jquery.timeago.js
index 34cdd7fd..de9dd94b 100644
--- a/jquery.timeago.js
+++ b/jquery.timeago.js
@@ -11,7 +11,7 @@
* Licensed under the MIT:
* http://www.opensource.org/licenses/mit-license.php
*
- * Copyright (c) 2008, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)
+ * Copyright (c) 2008-2009, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)
*/
(function($) {
$.timeago = function(timestamp) {
From 1eee427cc43ed25d9bad2599f9a1567a392da4b3 Mon Sep 17 00:00:00 2001
From: Ryan McGeary
Date: Sat, 7 Feb 2009 10:59:11 -0500
Subject: [PATCH 02/16] readme updated
---
README.markdown | 4 ++++
index.html | 4 +++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/README.markdown b/README.markdown
index dc06ac45..66e767f8 100644
--- a/README.markdown
+++ b/README.markdown
@@ -33,6 +33,10 @@ As time passes, the timestamps will automatically update.
**For different language configurations**: [http://gist.github.com/6251](http://gist.github.com/6251)
+## Author
+
+[Ryan McGeary](http://ryan.mcgeary.org) ([@rmm5t](http://twitter.com/rmm5t))
+
## Other
[MIT License](http://www.opensource.org/licenses/mit-license.php)
diff --git a/index.html b/index.html
index 0b7ebc45..388e5487 100644
--- a/index.html
+++ b/index.html
@@ -131,7 +131,8 @@ Where?
Who?
Timeago was built by Ryan McGeary
- while standing on the shoulders of giants. John Resig wrote about
+ (@rmm5t) while standing on the
+ shoulders of giants. John Resig wrote about
a similar
approach. The verbiage was based on
the distance_of_time_in_words ActionView helper
@@ -160,6 +161,7 @@
Huh?
License
Copyright © 2008-2009 Ryan McGeary
+ (@rmm5t)
From d9e4ff342c9c468ed14e27eb254b41e6c925e198 Mon Sep 17 00:00:00 2001
From: Ryan McGeary
Date: Thu, 12 Feb 2009 18:25:16 -0500
Subject: [PATCH 03/16] punctuation doc fix
---
index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.html b/index.html
index 388e5487..e1b3d813 100644
--- a/index.html
+++ b/index.html
@@ -67,7 +67,7 @@ What?
Why?
Timeago was originally built for use with Yarp.com to timestamp comments.
- - Avoid timestamps dated "1 minute ago" even though the page was opened 10 minutes ago; timeago refreshes automatically,
+ - Avoid timestamps dated "1 minute ago" even though the page was opened 10 minutes ago; timeago refreshes automatically.
- You can take full advantage of page caching in your web applications, because the timestamps aren't calculated on the server.
- You get to use microformats like the cool kids.
From 579b5c6f05608b7c2e167d2953f9c71bf95a1cb5 Mon Sep 17 00:00:00 2001
From: Ryan McGeary
Date: Sat, 14 Feb 2009 14:09:53 -0500
Subject: [PATCH 04/16] Added the ability to pass a function as a locale
override [DimaD]
* Good for cyrillic languages, like Russian
---
jquery.timeago.js | 16 ++++++-------
test.html | 18 +++-----------
test.js | 60 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+), 23 deletions(-)
diff --git a/jquery.timeago.js b/jquery.timeago.js
index de9dd94b..37ef99e8 100644
--- a/jquery.timeago.js
+++ b/jquery.timeago.js
@@ -63,17 +63,17 @@
var days = hours / 24;
var years = days / 365;
- var words = seconds < 45 && sprintf($l.seconds, Math.round(seconds)) ||
+ var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
seconds < 90 && $l.minute ||
- minutes < 45 && sprintf($l.minutes, Math.round(minutes)) ||
+ minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
minutes < 90 && $l.hour ||
- hours < 24 && sprintf($l.hours, Math.round(hours)) ||
+ hours < 24 && substitute($l.hours, Math.round(hours)) ||
hours < 48 && $l.day ||
- days < 30 && sprintf($l.days, Math.floor(days)) ||
+ days < 30 && substitute($l.days, Math.floor(days)) ||
days < 60 && $l.month ||
- days < 365 && sprintf($l.months, Math.floor(days / 30)) ||
+ days < 365 && substitute($l.months, Math.floor(days / 30)) ||
years < 2 && $l.year ||
- sprintf($l.years, Math.floor(years));
+ substitute($l.years, Math.floor(years));
return $.trim([prefix, words, suffix].join(" "));
},
@@ -113,8 +113,8 @@
return (new Date().getTime() - date.getTime());
}
- // lame sprintf implementation
- function sprintf(string, value) {
+ function substitute(stringOrFunction, value) {
+ var string = $.isFunction(stringOrFunction) ? stringOrFunction(value) : stringOrFunction;
return string.replace(/%d/i, value);
}
diff --git a/test.html b/test.html
index aef534ea..ea839eb0 100644
--- a/test.html
+++ b/test.html
@@ -9,21 +9,9 @@
-
-
-
-
-
-
- Functional tests:
-
- Short term
- You opened this page sometime before now.
- This page was last modified sometime before now (your browser might not support document.lastModified for local resources).
-
- Long term
- Jett was born bleh [from Z]
- Jett was born bleh [from -0500]
-
- Logan was born bleh [from Z]
- Logan was born bleh [from -0400]
-
- Ryan was born bleh [from Z]
- Ryan was born bleh [from -0500]
-
- Other formats
- Date only: (you shouldn't see this).
-
- Errors
- Bad (letters): (this should be displayed).
- Bad (numbers): (this should be displayed).
- Bad (blank): (this should be displayed).
- Bad (missing): (this should be displayed).
-
- Parsing unit tests:
- Ryan was born...
- [from Z]
- [from -00:00]
- [from -05:00]
- [from -0500]
- [from +09:00]
- [from +0900]
- [from blank TZ]
-
- Wording unit tests:
- [-120 min]
- [-60 sec]
- [-30 sec]
- [-1 sec]
- [0 sec]
- [30 sec]
- [45 sec]
- [90 sec]
- [120 sec]
- [45 min]
- [89 min]
- [90 min]
- [120 min]
- [1380 min]
- [25 hours]
- [48 hours]
- [696 hours]
- [30 days]
- [190 days]
- [366 days]
- [1095 days]
-
- Helper unit tests:
- You opened this page [won't refresh]
- You opened this page [won't refresh]
- You opened this page [won't refresh]
-
-