...

Source file src/time/export_test.go

Documentation: time

		 1  // Copyright 2013 The Go Authors. All rights reserved.
		 2  // Use of this source code is governed by a BSD-style
		 3  // license that can be found in the LICENSE file.
		 4  
		 5  package time
		 6  
		 7  import (
		 8  	"sync"
		 9  )
		10  
		11  func ResetLocalOnceForTest() {
		12  	localOnce = sync.Once{}
		13  	localLoc = Location{}
		14  }
		15  
		16  func ForceUSPacificForTesting() {
		17  	ResetLocalOnceForTest()
		18  	localOnce.Do(initTestingZone)
		19  }
		20  
		21  func ZoneinfoForTesting() *string {
		22  	return zoneinfo
		23  }
		24  
		25  func ResetZoneinfoForTesting() {
		26  	zoneinfo = nil
		27  	zoneinfoOnce = sync.Once{}
		28  }
		29  
		30  var (
		31  	ForceZipFileForTesting = forceZipFileForTesting
		32  	ParseTimeZone					= parseTimeZone
		33  	SetMono								= (*Time).setMono
		34  	GetMono								= (*Time).mono
		35  	ErrLocation						= errLocation
		36  	ReadFile							 = readFile
		37  	LoadTzinfo						 = loadTzinfo
		38  	NextStdChunk					 = nextStdChunk
		39  	Tzset									= tzset
		40  	TzsetName							= tzsetName
		41  	TzsetOffset						= tzsetOffset
		42  )
		43  
		44  func LoadFromEmbeddedTZData(zone string) (string, error) {
		45  	return loadFromEmbeddedTZData(zone)
		46  }
		47  
		48  type RuleKind int
		49  
		50  const (
		51  	RuleJulian			 = RuleKind(ruleJulian)
		52  	RuleDOY					= RuleKind(ruleDOY)
		53  	RuleMonthWeekDay = RuleKind(ruleMonthWeekDay)
		54  	UnixToInternal	 = unixToInternal
		55  )
		56  
		57  type Rule struct {
		58  	Kind RuleKind
		59  	Day	int
		60  	Week int
		61  	Mon	int
		62  	Time int
		63  }
		64  
		65  func TzsetRule(s string) (Rule, string, bool) {
		66  	r, rs, ok := tzsetRule(s)
		67  	rr := Rule{
		68  		Kind: RuleKind(r.kind),
		69  		Day:	r.day,
		70  		Week: r.week,
		71  		Mon:	r.mon,
		72  		Time: r.time,
		73  	}
		74  	return rr, rs, ok
		75  }
		76  
		77  // StdChunkNames maps from nextStdChunk results to the matched strings.
		78  var StdChunkNames = map[int]string{
		79  	0:															 "",
		80  	stdLongMonth:										"January",
		81  	stdMonth:												"Jan",
		82  	stdNumMonth:										 "1",
		83  	stdZeroMonth:										"01",
		84  	stdLongWeekDay:									"Monday",
		85  	stdWeekDay:											"Mon",
		86  	stdDay:													"2",
		87  	stdUnderDay:										 "_2",
		88  	stdZeroDay:											"02",
		89  	stdUnderYearDay:								 "__2",
		90  	stdZeroYearDay:									"002",
		91  	stdHour:												 "15",
		92  	stdHour12:											 "3",
		93  	stdZeroHour12:									 "03",
		94  	stdMinute:											 "4",
		95  	stdZeroMinute:									 "04",
		96  	stdSecond:											 "5",
		97  	stdZeroSecond:									 "05",
		98  	stdLongYear:										 "2006",
		99  	stdYear:												 "06",
	 100  	stdPM:													 "PM",
	 101  	stdpm:													 "pm",
	 102  	stdTZ:													 "MST",
	 103  	stdISO8601TZ:										"Z0700",
	 104  	stdISO8601SecondsTZ:						 "Z070000",
	 105  	stdISO8601ShortTZ:							 "Z07",
	 106  	stdISO8601ColonTZ:							 "Z07:00",
	 107  	stdISO8601ColonSecondsTZ:				"Z07:00:00",
	 108  	stdNumTZ:												"-0700",
	 109  	stdNumSecondsTz:								 "-070000",
	 110  	stdNumShortTZ:									 "-07",
	 111  	stdNumColonTZ:									 "-07:00",
	 112  	stdNumColonSecondsTZ:						"-07:00:00",
	 113  	stdFracSecond0 | 1<<stdArgShift: ".0",
	 114  	stdFracSecond0 | 2<<stdArgShift: ".00",
	 115  	stdFracSecond0 | 3<<stdArgShift: ".000",
	 116  	stdFracSecond0 | 4<<stdArgShift: ".0000",
	 117  	stdFracSecond0 | 5<<stdArgShift: ".00000",
	 118  	stdFracSecond0 | 6<<stdArgShift: ".000000",
	 119  	stdFracSecond0 | 7<<stdArgShift: ".0000000",
	 120  	stdFracSecond0 | 8<<stdArgShift: ".00000000",
	 121  	stdFracSecond0 | 9<<stdArgShift: ".000000000",
	 122  	stdFracSecond9 | 1<<stdArgShift: ".9",
	 123  	stdFracSecond9 | 2<<stdArgShift: ".99",
	 124  	stdFracSecond9 | 3<<stdArgShift: ".999",
	 125  	stdFracSecond9 | 4<<stdArgShift: ".9999",
	 126  	stdFracSecond9 | 5<<stdArgShift: ".99999",
	 127  	stdFracSecond9 | 6<<stdArgShift: ".999999",
	 128  	stdFracSecond9 | 7<<stdArgShift: ".9999999",
	 129  	stdFracSecond9 | 8<<stdArgShift: ".99999999",
	 130  	stdFracSecond9 | 9<<stdArgShift: ".999999999",
	 131  }
	 132  
	 133  var Quote = quote
	 134  

View as plain text