github.com/keysonZZZ/kmg@v0.0.0-20151121023212-05317bfd7d39/kmgTime/time_test.go (about)

     1  package kmgTime
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/bronze1man/kmg/kmgTest"
     7  )
     8  
     9  func TestMustFromMysqlFormatDefaultTZ(ot *testing.T) {
    10  	t := MustFromMysqlFormatDefaultTZ("2001-01-01 00:00:00")
    11  	kmgTest.Equal(t.Hour(), 0)
    12  	kmgTest.Equal(t.Day(), 1)
    13  
    14  	t = MustFromMysqlFormatDefaultTZ("0000-00-00 00:00:00")
    15  	kmgTest.Equal(t.IsZero(), true)
    16  }
    17  
    18  const localTime string = "2015-11-12 14:15:55"
    19  
    20  
    21  func TestFixLocalTimeToOffsetSpecifiedZoneTime(ot *testing.T){
    22  	otherZoneTime := FixLocalTimeToOffsetSpecifiedZoneTime(3600, localTime)
    23  	kmgTest.Equal(otherZoneTime, "2015-11-12 07:15:55")
    24  	otherZoneTime = FixLocalTimeToOffsetSpecifiedZoneTime(7200, localTime)
    25  	kmgTest.Equal(otherZoneTime, "2015-11-12 08:15:55")
    26  	otherZoneTime = FixLocalTimeToOffsetSpecifiedZoneTime(-18000, localTime)
    27  	kmgTest.Equal(otherZoneTime, "2015-11-12 01:15:55")
    28  }