Add time format
This commit is contained in:
		| @@ -21,7 +21,7 @@ export default class UpgradeBuildingAction extends ActionController { | ||||
|             this.scheduler.completeTask(task.id); | ||||
|             btn.trigger('click'); | ||||
|         } else { | ||||
|             throw new TryLaterError(60, 'No upgrade button, try later'); | ||||
|             throw new TryLaterError(5 * 60, 'No upgrade button, try later'); | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
|   | ||||
| @@ -148,7 +148,7 @@ export default class Scheduler { | ||||
|             if (e instanceof TryLaterError) { | ||||
|                 console.warn('TRY', task.id, 'AFTER', e.seconds); | ||||
|                 this.actionQueue.clear(); | ||||
|                 this.taskQueue.postpone(task.id, e.seconds); | ||||
|                 this.taskQueue.postpone(task.id, timestamp() + e.seconds); | ||||
|                 this.nextSleepLong(); | ||||
|             } | ||||
|         } | ||||
|   | ||||
| @@ -54,11 +54,11 @@ export class TaskQueue { | ||||
|         this.flushItems(items); | ||||
|     } | ||||
|  | ||||
|     postpone(id: TaskId, deltaSeconds: number) { | ||||
|     postpone(id: TaskId, newTs: number) { | ||||
|         const [task, items] = this.shiftTask(id); | ||||
|         if (task) { | ||||
|             this.log('POSTPONE', task); | ||||
|             items.push(task.withTime(task.ts + deltaSeconds)); | ||||
|             items.push(task.withTime(newTs)); | ||||
|         } | ||||
|         this.flushItems(items); | ||||
|     } | ||||
|   | ||||
| @@ -1,8 +1,14 @@ | ||||
| import { TaskList } from './Storage/TaskQueue'; | ||||
| import { uniqId } from './utils'; | ||||
| import dateFormat = require('dateformat'); | ||||
|  | ||||
| const ID = uniqId(); | ||||
|  | ||||
| function formatDate(ts: number) { | ||||
|     const d = new Date(ts * 1000); | ||||
|     return dateFormat(d, 'HH:MM:ss'); | ||||
| } | ||||
|  | ||||
| export default class TaskQueueRenderer { | ||||
|     render(tasks: TaskList) { | ||||
|         const ul = jQuery('<ul></ul>') | ||||
| @@ -19,7 +25,7 @@ export default class TaskQueueRenderer { | ||||
|         tasks.forEach(task => { | ||||
|             ul.append( | ||||
|                 jQuery('<li></li>').text( | ||||
|                     task.ts + | ||||
|                     formatDate(task.ts) + | ||||
|                         ' ' + | ||||
|                         task.cmd.name + | ||||
|                         ' ' + | ||||
|   | ||||
		Reference in New Issue
	
	Block a user