OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Parse "zoneinfo" time zone file. | 5 // Parse "zoneinfo" time zone file. |
6 // This is a fairly standard file format used on OS X, Linux, BSD, Sun, and othe
rs. | 6 // This is a fairly standard file format used on OS X, Linux, BSD, Sun, and othe
rs. |
7 // See tzfile(5), http://en.wikipedia.org/wiki/Zoneinfo, | 7 // See tzfile(5), http://en.wikipedia.org/wiki/Zoneinfo, |
8 // and ftp://munnari.oz.au/pub/oldtz/ | 8 // and ftp://munnari.oz.au/pub/oldtz/ |
9 | 9 |
10 package time | 10 package time |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 if i < len(isutc) { | 172 if i < len(isutc) { |
173 tx[i].isutc = isutc[i] != 0 | 173 tx[i].isutc = isutc[i] != 0 |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 // Commited to succeed. | 177 // Commited to succeed. |
178 l = &Location{zone: zone, tx: tx} | 178 l = &Location{zone: zone, tx: tx} |
179 | 179 |
180 // Fill in the cache with information about right now, | 180 // Fill in the cache with information about right now, |
181 // since that will be the most common lookup. | 181 // since that will be the most common lookup. |
182 » sec, _ := now() | 182 » sec, _ := fakeNow() |
183 for i := range tx { | 183 for i := range tx { |
184 if tx[i].when <= sec && (i+1 == len(tx) || sec < tx[i+1].when) { | 184 if tx[i].when <= sec && (i+1 == len(tx) || sec < tx[i+1].when) { |
185 l.cacheStart = tx[i].when | 185 l.cacheStart = tx[i].when |
186 l.cacheEnd = 1<<63 - 1 | 186 l.cacheEnd = 1<<63 - 1 |
187 if i+1 < len(tx) { | 187 if i+1 < len(tx) { |
188 l.cacheEnd = tx[i+1].when | 188 l.cacheEnd = tx[i+1].when |
189 } | 189 } |
190 l.cacheZone = &l.zone[tx[i].index] | 190 l.cacheZone = &l.zone[tx[i].index] |
191 } | 191 } |
192 } | 192 } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 buf = make([]byte, size) | 332 buf = make([]byte, size) |
333 if err := preadn(fd, buf, off+30+namelen+xlen); err != nil { | 333 if err := preadn(fd, buf, off+30+namelen+xlen); err != nil { |
334 return nil, errors.New("corrupt zip file " + zipfile) | 334 return nil, errors.New("corrupt zip file " + zipfile) |
335 } | 335 } |
336 | 336 |
337 return loadZoneData(buf) | 337 return loadZoneData(buf) |
338 } | 338 } |
339 | 339 |
340 return nil, errors.New("cannot find " + name + " in zip file " + zipfile
) | 340 return nil, errors.New("cannot find " + name + " in zip file " + zipfile
) |
341 } | 341 } |
OLD | NEW |