Skip to content

Commit

Permalink
Humanize timestamp is a helper function to fix compiler error caused …
Browse files Browse the repository at this point in the history
…by newer version of master
  • Loading branch information
Calvin Pomerantz committed Mar 14, 2016
1 parent 201e719 commit 4df6f5c
Showing 1 changed file with 14 additions and 12 deletions.
Expand Up @@ -57,13 +57,25 @@ public MailTemplateHelpers(SandboxManager sandboxManager, SingularityConfigurati
}
}

public String humanizeTimestamp(long timestamp) {
if (taskDatePattern.isPresent() && timeZone.isPresent()) {
return DateFormatUtils.format(timestamp, taskDatePattern.get(), timeZone.get());
} else if (taskDatePattern.isPresent()) {
return DateFormatUtils.formatUTC(timestamp, taskDatePattern.get());
} else if (timeZone.isPresent()) {
return DateFormatUtils.format(timestamp, DEFAULT_TIMESTAMP_FORMAT, timeZone.get());
} else {
return DateFormatUtils.format(timestamp, DEFAULT_TIMESTAMP_FORMAT);
}
}

public List<SingularityMailTaskMetadata> getJadeTaskMetadata(Collection<SingularityTaskMetadata> taskMetadata) {
List<SingularityMailTaskMetadata> output = Lists.newArrayListWithCapacity(taskMetadata.size());

for (SingularityTaskMetadata metadataElement : taskMetadata) {
output.add(
new SingularityMailTaskMetadata(
DateFormatUtils.formatUTC(metadataElement.getTimestamp(), TASK_DATE_PATTERN),
humanizeTimestamp(metadataElement.getTimestamp()),
metadataElement.getType(),
metadataElement.getTitle(),
metadataElement.getUser().or(""),
Expand All @@ -78,19 +90,9 @@ public List<SingularityMailTaskHistoryUpdate> getJadeTaskHistory(Collection<Sing
List<SingularityMailTaskHistoryUpdate> output = Lists.newArrayListWithCapacity(taskHistory.size());

for (SingularityTaskHistoryUpdate taskUpdate : taskHistory) {
String date;
if (taskDatePattern.isPresent() && timeZone.isPresent()) {
date = DateFormatUtils.format(taskUpdate.getTimestamp(), taskDatePattern.get(), timeZone.get());
} else if (taskDatePattern.isPresent()) {
date = DateFormatUtils.formatUTC(taskUpdate.getTimestamp(), taskDatePattern.get());
} else if (timeZone.isPresent()) {
date = DateFormatUtils.format(taskUpdate.getTimestamp(), DEFAULT_TIMESTAMP_FORMAT, timeZone.get());
} else {
date = DateFormatUtils.format(taskUpdate.getTimestamp(), DEFAULT_TIMESTAMP_FORMAT);
}
output.add(
new SingularityMailTaskHistoryUpdate(
date,
humanizeTimestamp(taskUpdate.getTimestamp()),
WordUtils.capitalize(taskUpdate.getTaskState().getDisplayName()),
taskUpdate.getStatusMessage().or("")));
}
Expand Down

0 comments on commit 4df6f5c

Please sign in to comment.