File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change 77// StdTime gets standard time.Time. 
88// 获取标准 time.Time 
99func  (c  * Carbon ) StdTime () time.Time  {
10+ 	if  c .IsInvalid () {
11+ 		return  time.Time {}
12+ 	}
1013	if  c .loc  ==  nil  {
1114		return  c .time 
1215	}
Original file line number Diff line number Diff line change @@ -28,6 +28,13 @@ func TestCarbon_StdTime(t *testing.T) {
2828		c  :=  Parse ("2020-08-05" , PRC )
2929		assert .Equal (t , "2020-08-05 00:00:00 +0800 CST" , c .StdTime ().String ())
3030	})
31+ 
32+ 	// https://github.com/dromara/carbon/issues/294 
33+ 	t .Run ("issue294" , func (t  * testing.T ) {
34+ 		assert .Equal (t , "0001-01-01 00:00:00 +0000 UTC" , Parse ("" ).StdTime ().String ())
35+ 		assert .Equal (t , "0001-01-01 00:00:00 +0000 UTC" , Parse ("0" ).StdTime ().String ())
36+ 		assert .Equal (t , "0001-01-01 00:00:00 +0000 UTC" , Parse ("xxx" ).StdTime ().String ())
37+ 	})
3138}
3239
3340func  TestCarbon_DaysInYear (t  * testing.T ) {
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments