Commit d13cd581fae43189141158213f985cf4d12c7b96
- Diff rendering mode:
- inline
- side by side
entry.class.php
(24 / 16)
|   | |||
| 55 | 55 | $units['month'] = 60*60*24*30; | |
| 56 | 56 | $units['year'] = 60*60*24*365; | |
| 57 | 57 | ||
| 58 | foreach($units as $unit=>$value){ | ||
| 59 | # Base case (0 seconds ago) | ||
| 60 | if($timeSince == 0) | ||
| 61 | $timeSinceString = 'just now'; | ||
| 62 | # Otherwise | ||
| 63 | else if($timeSince < $value or $unit == 'year'){ | ||
| 64 | $timeSince = floor($timeSince/$prev_value); | ||
| 65 | if($timeSince != 1) | ||
| 66 | $prev_unit .= 's'; | ||
| 67 | $timeSinceString = "about $timeSince $prev_unit ago"; | ||
| 68 | break; | ||
| 69 | } | ||
| 70 | $prev_unit = $unit; | ||
| 71 | $prev_value = $value; | ||
| 72 | } | ||
| 73 | #TODO: Handle styles with XSLT | ||
| 58 | # Override 'units ago' for hard date | ||
| 59 | #TODO: make override dynamic depending on proximity to surrounding dates | ||
| 60 | $override = $units['month']; | ||
| 61 | |||
| 62 | if ($timeSince > $override) { echo 'here'; | ||
| 63 | $timeSinceString = date('\o\n M j Y \a\t g:i a', $this->rec_updated); | ||
| 64 | } else { | ||
| 65 | foreach($units as $unit=>$value){ | ||
| 66 | # Base case (0 seconds ago) | ||
| 67 | if($timeSince == 0) | ||
| 68 | $timeSinceString = 'just now'; | ||
| 69 | # Otherwise | ||
| 70 | else if($timeSince < $value or $unit == 'year'){ | ||
| 71 | $timeSince = floor($timeSince/$prev_value); | ||
| 72 | if($timeSince != 1) | ||
| 73 | $prev_unit .= 's'; | ||
| 74 | $timeSinceString = "about $timeSince $prev_unit ago"; | ||
| 75 | break; | ||
| 76 | } | ||
| 77 | $prev_unit = $unit; | ||
| 78 | $prev_value = $value; | ||
| 79 | } | ||
| 80 | } | ||
| 81 | #TODO: Handle styles elsewhere | ||
| 74 | 82 | return "<span style='font-size:small;color:#999;'>$timeSinceString</span>"; | |
| 75 | 83 | } | |
| 76 | 84 |

