Skip to content

Commit

Permalink
if we can't get a date for an obs, show unknown
Browse files Browse the repository at this point in the history
instead of (null) (null)

still not sure why we're not getting dates for new observations,
haven't been able to replicate.

this is for #684
  • Loading branch information
alexshepard committed Sep 24, 2024
1 parent 4d7f242 commit 60b9d44
Showing 1 changed file with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1577,24 +1577,28 @@ - (UITableViewCell *)notesCellInTableView:(UITableView *)tableView {

- (UITableViewCell *)dateTimeCellInTableView:(UITableView *)tableView {
DisclosureCell *cell = [tableView dequeueReusableCellWithIdentifier:@"disclosure"];

cell.titleLabel.text = [self.standaloneObservation observedOnShortString];

NSDateFormatter *tzFormat = [[NSDateFormatter alloc] init];
tzFormat.dateFormat = @"ZZZZZ";
if (self.standaloneObservation.observedTimeZone) {
NSTimeZone *tz = [NSTimeZone timeZoneWithName:self.standaloneObservation.observedTimeZone];
if (tz) {
tzFormat.timeZone = tz;

if (self.standaloneObservation.observedOn && self.standaloneObservation.observedOnShortString) {
cell.titleLabel.text = [self.standaloneObservation observedOnShortString];

NSDateFormatter *tzFormat = [[NSDateFormatter alloc] init];
tzFormat.dateFormat = @"ZZZZZ";
if (self.standaloneObservation.observedTimeZone) {
NSTimeZone *tz = [NSTimeZone timeZoneWithName:self.standaloneObservation.observedTimeZone];
if (tz) {
tzFormat.timeZone = tz;
}
}
NSString *tzString = [tzFormat stringFromDate:self.standaloneObservation.observedOn];
cell.titleLabel.text = [NSString stringWithFormat:@"%@ %@", cell.titleLabel.text, tzString];
} else {
cell.titleLabel.text = NSLocalizedString(@"Unknown", @"unknown datetime");
}
NSString *tzString = [tzFormat stringFromDate:self.standaloneObservation.observedOn];
cell.titleLabel.text = [NSString stringWithFormat:@"%@ %@", cell.titleLabel.text, tzString];


FAKIcon *calendar = [FAKINaturalist iosCalendarOutlineIconWithSize:44];
[calendar addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#777777"]];
cell.cellImageView.image = [calendar imageWithSize:CGSizeMake(44, 44)];

cell.selectionStyle = UITableViewCellSelectionStyleDefault;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
Expand Down

0 comments on commit 60b9d44

Please sign in to comment.