long () { long timeSpent = 0; if (myLastPost != null) { for (WorkItem item : myWorkItems) { if (item.from.getTime() < myLastPost.getTime()) { if (item.from.getTime() + item.duration > myLastPost.getTime()) { timeSpent += item.from.getTime() + item.duration - myLastPost.getTime(); } } else { timeSpent += item.duration; } } } else { for (WorkItem item : myWorkItems) { timeSpent += item.duration; } } return timeSpent; }