Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: ejschmitt/delayed_job_web
base: 8d766217a2
...
head fork: ejschmitt/delayed_job_web
compare: 11589d7aa8
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Commits on May 14, 2012
@ferlatte ferlatte Fix relatizing future dates. b35b988
Commits on May 18, 2012
@ejschmitt Merge pull request #11 from ferlatte/fix-future-relative-time
Fix relatizing future dates.
11589d7
View
31 lib/delayed_job_web/application/public/javascripts/jquery.relatize_date.js
@@ -28,7 +28,7 @@
var day = date.getDay(), month = date.getMonth();
var hours = date.getHours(), minutes = date.getMinutes();
- var pad = function(num) {
+ var pad = function(num) {
var string = num.toString(10);
return new Array((2 - string.length) + 1).join('0') + string
};
@@ -53,11 +53,11 @@
}
})
},
-
+
timeAgoInWords: function(targetDate, includeTime) {
return $r.distanceOfTimeInWords(targetDate, new Date(), includeTime);
},
-
+
/**
* Return the distance of time in words between two Date's
* Example: '5 days ago', 'about an hour ago'
@@ -67,7 +67,30 @@
*/
distanceOfTimeInWords: function(fromTime, toTime, includeTime) {
var delta = parseInt((toTime.getTime() - fromTime.getTime()) / 1000);
- if (delta < 60) {
+ if (delta < (-(48*60*60) - 1)) {
+ var daysfrom = parseInt(Math.abs(delta / 86400));
+ if (daysfrom > 5) {
+ var fmt = '%B %d, %Y';
+ if (includeTime) fmt += ' %I:%M %p';
+ return $r.strftime(fromTime, fmt);
+ } else {
+ return daysfrom + " days from now";
+ }
+ } else if (delta < -(48*60*60)) {
+ return '1 day from now';
+ } else if (delta < -(24*60*60)) {
+ return 'about ' + parseInt(Math.abs(delta / 3600)).toString() +
+ ' hours from now';
+ } else if (delta < -(120*60)) {
+ return 'about an hour from now';
+ } else if (delta < -(45*60)) {
+ return parseInt(Math.abs(delta / 60)).toString()
+ + ' minutes from now';
+ } else if (delta < -60) {
+ return 'about a minute from now';
+ } else if (delta < 0) {
+ return 'less than a minute from now';
+ } else if (delta < 60) {
return 'less than a minute ago';
} else if (delta < 120) {
return 'about a minute ago';

No commit comments for this range

Something went wrong with that request. Please try again.