mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	Show how much time ago was the release.
This commit is contained in:
		
							parent
							
								
									d5913cbb28
								
							
						
					
					
						commit
						ad6f3cb6ee
					
				@ -52,10 +52,12 @@ class Mage_Task_BuiltIn_Releases_List
 | 
				
			|||||||
                        $isCurrent = ' <- current';
 | 
					                        $isCurrent = ' <- current';
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    
 | 
					                    
 | 
				
			||||||
 | 
					                    $dateDiff = $this->_dateDiff($releaseDate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    Mage_Console::output(
 | 
					                    Mage_Console::output(
 | 
				
			||||||
                        'Release: <purple>' . $release . '</purple> '
 | 
					                        'Release: <purple>' . $release . '</purple> '
 | 
				
			||||||
                      . '- Date: <dark_gray>' . $releaseDate . '</dark_gray> '
 | 
					                      . '- Date: <dark_gray>' . $releaseDate . '</dark_gray> '
 | 
				
			||||||
                      . '- Index: <dark_gray>' . $releaseIndex . '</dark_gray>' . $isCurrent, 2);
 | 
					                      . '- Index: <dark_gray>' . $releaseIndex . '</dark_gray>' . $dateDiff . $isCurrent, 2);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -68,4 +70,52 @@ class Mage_Task_BuiltIn_Releases_List
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    private function _dateDiff($releaseDate)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $textDiff = '';
 | 
				
			||||||
 | 
					        $releaseDate = new DateTime($releaseDate);
 | 
				
			||||||
 | 
					        $now = new DateTime();
 | 
				
			||||||
 | 
					        $diff = $now->diff($releaseDate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($diff->format('%a') <= 7) {
 | 
				
			||||||
 | 
					            if ($diff->format('%d') == 7) {
 | 
				
			||||||
 | 
					                $textDiff = ' [a week ago] ';
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					            } else if ($diff->format('%d') > 0 && $diff->format('%d') < 7) {
 | 
				
			||||||
 | 
					                $days = $diff->format('%d');
 | 
				
			||||||
 | 
					                if ($days <= 1) {
 | 
				
			||||||
 | 
					                    $textDiff = ' [one day ago] ';
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    $textDiff = ' [' . $days . ' days ago] ';
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					            } else if ($diff->format('%d') == 0 && $diff->format('%h') > 0) {
 | 
				
			||||||
 | 
					                $hours = $diff->format('%h');
 | 
				
			||||||
 | 
					                if ($hours <= 1) {
 | 
				
			||||||
 | 
					                    $textDiff = ' [one hour ago] ';
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    $textDiff = ' [' . $hours . ' hours ago] ';
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					            } else if ($diff->format('%d') == 0 && $diff->format('%h') == 0) {
 | 
				
			||||||
 | 
					                $minutes = $diff->format('%i');
 | 
				
			||||||
 | 
					                if ($minutes <= 1) {
 | 
				
			||||||
 | 
					                    $textDiff = ' [one minute ago] ';
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    $textDiff = ' [' . $minutes . ' minutes ago] ';
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					            } else if ($diff->format('%d') == 0 && $diff->format('%h') == 0 && $diff->format('%i') == 0) {
 | 
				
			||||||
 | 
					                $seconds = $diff->format('%s');
 | 
				
			||||||
 | 
					                if ($seconds < 10) {
 | 
				
			||||||
 | 
					                    $textDiff = ' [just now!] ';
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    $textDiff = ' [' . $seconds . ' seconds ago] ';
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $textDiff;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user