Skip to content

Commit

Permalink
avoiding show 'NaN days ago' setting job run_at time using an iso8601…
Browse files Browse the repository at this point in the history
… date format

Conflicts:

	lib/resque/worker.rb
  • Loading branch information
wandenberg authored and steveklabnik committed Dec 15, 2012
1 parent cb05cb3 commit df08385
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/resque/server/public/jquery.relatize_date.js
Expand Up @@ -67,21 +67,21 @@
* @param {Boolean} Include the time in the output
*/
distanceOfTimeInWords: function(fromTime, toTime, includeTime) {
var delta = parseInt((toTime.getTime() - fromTime.getTime()) / 1000);
var delta = parseInt((toTime.getTime() - fromTime.getTime()) / 1000, 10);
if (delta < 60) {
return 'just now';
} else if (delta < 120) {
return 'about a minute ago';
} else if (delta < (45*60)) {
return (parseInt(delta / 60)).toString() + ' minutes ago';
return (parseInt(delta / 60, 10)).toString() + ' minutes ago';
} else if (delta < (120*60)) {
return 'about an hour ago';
} else if (delta < (24*60*60)) {
return 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago';
return 'about ' + (parseInt(delta / 3600, 10)).toString() + ' hours ago';
} else if (delta < (48*60*60)) {
return '1 day ago';
} else {
var days = (parseInt(delta / 86400)).toString();
var days = (parseInt(delta / 86400, 10)).toString();
if (days > 5) {
var fmt = '%B %d, %Y'
if (includeTime) fmt += ' %I:%M %p'
Expand Down
2 changes: 1 addition & 1 deletion lib/resque/worker.rb
Expand Up @@ -459,7 +459,7 @@ def unregister_worker(exception = nil)
def working_on(job)
data = encode \
:queue => job.queue,
:run_at => Time.now.rfc2822,
:run_at => Time.now.utc.iso8601,
:payload => job.payload
redis.set("worker:#{self}", data)
end
Expand Down
7 changes: 7 additions & 0 deletions test/worker_test.rb
Expand Up @@ -46,6 +46,13 @@
@worker.perform job
end
end

test "register 'run_at' time on UTC timezone in ISO8601 format" do
job = Resque::Job.new(:jobs, {'class' => 'GoodJob', 'args' => "blah"})
now = Time.now.utc.iso8601
@worker.working_on(job)
assert_equal now, @worker.processing['run_at']
end

it "fails uncompleted jobs with DirtyExit by default on exit" do
job = Resque::Job.new(:jobs, {'class' => 'GoodJob', 'args' => "blah"})
Expand Down

0 comments on commit df08385

Please sign in to comment.