Use NSRelativeDateTimeFormatter when running on macOS 10.15

This commit is contained in:
Allan Odgaard
2020-04-28 15:59:54 +07:00
parent e6ceaf86b4
commit e15798bac3

View File

@@ -51,7 +51,16 @@
- (void)updateLastPollString:(id)sender
{
self.lastPollString = [self.lastPoll humanReadableTimeElapsed];
if(@available(macos 10.15, *))
{
NSRelativeDateTimeFormatter* formatter = [[NSRelativeDateTimeFormatter alloc] init];
formatter.dateTimeStyle = NSRelativeDateTimeFormatterStyleNamed;
self.lastPollString = [formatter localizedStringForDate:_lastPoll relativeToDate:NSDate.now];
}
else
{
self.lastPollString = [self.lastPoll humanReadableTimeElapsed];
}
}
- (void)setLastPoll:(NSDate*)aDate