Improved the algorithms for #tdy, #tmr and #upc

#upc does not return the task which deadline was yesterday.