mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 06:37:55 +08:00 
			
		
		
		
	Fixes #15286: Fixed incorrect formatting of time with timezone information
This commit is contained in:
		
				
					committed by
					
						
						Alexander Makarov
					
				
			
			
				
	
			
			
			
						parent
						
							e3b7581bca
						
					
				
				
					commit
					22d30f1999
				
			@ -4,6 +4,7 @@ Yii Framework 2 Change Log
 | 
				
			|||||||
2.0.16 under development
 | 
					2.0.16 under development
 | 
				
			||||||
------------------------
 | 
					------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Bug #15286: Fixed incorrect formatting of time with timezone information (rugabarbo)
 | 
				
			||||||
- Bug #17021: Fix to do not remove existing message category files in a subfolder (albertborsos)
 | 
					- Bug #17021: Fix to do not remove existing message category files in a subfolder (albertborsos)
 | 
				
			||||||
- Bug #16991: Removed usage of `utf8_encode()` from `Request::resolvePathInfo()` (GHopperMSK)
 | 
					- Bug #16991: Removed usage of `utf8_encode()` from `Request::resolvePathInfo()` (GHopperMSK)
 | 
				
			||||||
- Bug #16974: Regular Expression Validator to include support for 'u' (UTF-8) modifier (Dzhuneyt)
 | 
					- Bug #16974: Regular Expression Validator to include support for 'u' (UTF-8) modifier (Dzhuneyt)
 | 
				
			||||||
 | 
				
			|||||||
@ -841,7 +841,7 @@ class Formatter extends Component
 | 
				
			|||||||
                return [
 | 
					                return [
 | 
				
			||||||
                    $timestamp,
 | 
					                    $timestamp,
 | 
				
			||||||
                    !($info['hour'] === false && $info['minute'] === false && $info['second'] === false),
 | 
					                    !($info['hour'] === false && $info['minute'] === false && $info['second'] === false),
 | 
				
			||||||
                    !($info['year'] === false && $info['month'] === false && $info['day'] === false),
 | 
					                    !($info['year'] === false && $info['month'] === false && $info['day'] === false && empty($info['zone'])),
 | 
				
			||||||
                ];
 | 
					                ];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -753,6 +753,28 @@ class FormatterDateTest extends TestCase
 | 
				
			|||||||
        $this->assertNotSame('12:00:00', $this->formatter->asDate('12:00:00', 'HH:mm:ss'));
 | 
					        $this->assertNotSame('12:00:00', $this->formatter->asDate('12:00:00', 'HH:mm:ss'));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @see https://github.com/yiisoft/yii2/issues/15286
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function testTimeWithTimezoneInfo()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->formatter->defaultTimeZone = 'UTC';
 | 
				
			||||||
 | 
					        $this->formatter->timeZone = 'Etc/GMT-3';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $time = '16:22:00.44297+03';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->formatter->timeFormat = 'php:H:i:s';
 | 
				
			||||||
 | 
					        $this->assertSame('16:22:00', $this->formatter->asTime($time));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->formatter->timeFormat = 'HH:mm:ss';
 | 
				
			||||||
 | 
					        $this->assertSame('16:22:00', $this->formatter->asTime($time));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function testIntlTimeWithTimezoneInfo()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->testTimeWithTimezoneInfo();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @see https://github.com/yiisoft/yii2/issues/6263.
 | 
					     * @see https://github.com/yiisoft/yii2/issues/6263.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user