summaryrefslogtreecommitdiff
path: root/src/lib/time
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/time')
-rw-r--r--src/lib/time/tick.go6
-rw-r--r--src/lib/time/time.go2
-rw-r--r--src/lib/time/zoneinfo.go34
3 files changed, 19 insertions, 23 deletions
diff --git a/src/lib/time/tick.go b/src/lib/time/tick.go
index f3df11c45..a4cb786c5 100644
--- a/src/lib/time/tick.go
+++ b/src/lib/time/tick.go
@@ -18,14 +18,14 @@ import (
// Also, if timeouts become part of the select statement,
// perhaps the Ticker is just:
//
-// func Ticker(ns int64, c *chan int64) {
+// func Ticker(ns int64, c chan int64) {
// for {
// select { timeout ns: }
// nsec, err := time.Nanoseconds();
// c <- nsec;
// }
-func Ticker(ns int64, c *chan int64) {
+func Ticker(ns int64, c chan int64) {
var tv syscall.Timeval;
now := time.Nanoseconds();
when := now;
@@ -49,7 +49,7 @@ func Ticker(ns int64, c *chan int64) {
}
}
-export func Tick(ns int64) *chan int64 {
+export func Tick(ns int64) chan int64 {
if ns <= 0 {
return nil
}
diff --git a/src/lib/time/time.go b/src/lib/time/time.go
index 2a6a3bf01..c067cbeff 100644
--- a/src/lib/time/time.go
+++ b/src/lib/time/time.go
@@ -71,7 +71,7 @@ const (
)
export func SecondsToUTC(sec int64) *Time {
- t := new(Time);
+ t := new(*Time);
// Split into time and day.
day := sec/SecondsPerDay;
diff --git a/src/lib/time/zoneinfo.go b/src/lib/time/zoneinfo.go
index 90d8adb9a..9ac9807ab 100644
--- a/src/lib/time/zoneinfo.go
+++ b/src/lib/time/zoneinfo.go
@@ -30,13 +30,12 @@ type Data struct {
error bool;
}
-var NIL []byte // TODO(rsc)
func (d *Data) Read(n int) []byte {
if len(d.p) < n {
- d.p = NIL;
+ d.p = nil;
d.error = true;
- return NIL;
+ return nil;
}
p := d.p[0:n];
d.p = d.p[n:len(d.p)];
@@ -86,20 +85,19 @@ type Zonetime struct {
}
func ParseZoneinfo(bytes []byte) (zt []Zonetime, err *os.Error) {
- var NIL []Zonetime; // TODO(rsc)
data1 := Data{bytes, false};
data := &data1;
// 4-byte magic "TZif"
if magic := data.Read(4); string(magic) != "TZif" {
- return NIL, BadZoneinfo
+ return nil, BadZoneinfo
}
// 1-byte version, then 15 bytes of padding
var p []byte;
if p = data.Read(16); len(p) != 16 || p[0] != 0 && p[0] != '2' {
- return NIL, BadZoneinfo
+ return nil, BadZoneinfo
}
vers := p[0];
@@ -122,7 +120,7 @@ func ParseZoneinfo(bytes []byte) (zt []Zonetime, err *os.Error) {
for i := 0; i < 6; i++ {
nn, ok := data.Big4();
if !ok {
- return NIL, BadZoneinfo
+ return nil, BadZoneinfo
}
n[i] = int(nn);
}
@@ -154,7 +152,7 @@ func ParseZoneinfo(bytes []byte) (zt []Zonetime, err *os.Error) {
isutc := data.Read(n[NUTCLocal]);
if data.error { // ran out of data
- return NIL, BadZoneinfo
+ return nil, BadZoneinfo
}
// If version == 2, the entire file repeats, this time using
@@ -169,16 +167,16 @@ func ParseZoneinfo(bytes []byte) (zt []Zonetime, err *os.Error) {
var ok bool;
var n uint32;
if n, ok = zonedata.Big4(); !ok {
- return NIL, BadZoneinfo
+ return nil, BadZoneinfo
}
zone[i].utcoff = int(n);
var b byte;
if b, ok = zonedata.Byte(); !ok {
- return NIL, BadZoneinfo
+ return nil, BadZoneinfo
}
zone[i].isdst = b != 0;
if b, ok = zonedata.Byte(); !ok || int(b) >= len(abbrev) {
- return NIL, BadZoneinfo
+ return nil, BadZoneinfo
}
zone[i].name = ByteString(abbrev[b:len(abbrev)])
}
@@ -189,11 +187,11 @@ func ParseZoneinfo(bytes []byte) (zt []Zonetime, err *os.Error) {
var ok bool;
var n uint32;
if n, ok = txtimes.Big4(); !ok {
- return NIL, BadZoneinfo
+ return nil, BadZoneinfo
}
zt[i].time = int32(n);
if int(txzones[i]) >= len(zone) {
- return NIL, BadZoneinfo
+ return nil, BadZoneinfo
}
zt[i].zone = &zone[txzones[i]];
if i < len(isstd) {
@@ -207,10 +205,9 @@ func ParseZoneinfo(bytes []byte) (zt []Zonetime, err *os.Error) {
}
func ReadFile(name string, max int) (p []byte, err *os.Error) {
- var NIL []byte; // TODO(rsc)
fd, e := os.Open(name, os.O_RDONLY, 0);
if e != nil {
- return NIL, e
+ return nil, e
}
p = new([]byte, max+1)[0:0];
n := 0;
@@ -218,7 +215,7 @@ func ReadFile(name string, max int) (p []byte, err *os.Error) {
nn, e := fd.Read(p[n:cap(p)]);
if e != nil {
fd.Close();
- return NIL, e
+ return nil, e
}
if nn == 0 {
fd.Close();
@@ -227,15 +224,14 @@ func ReadFile(name string, max int) (p []byte, err *os.Error) {
p = p[0:n+nn]
}
fd.Close();
- return NIL, BadZoneinfo // too long
+ return nil, BadZoneinfo // too long
}
func ReadZoneinfoFile(name string) (tx []Zonetime, err *os.Error) {
- var NIL []Zonetime; // TODO(rsc)
data, e := ReadFile(name, MaxFileSize);
if e != nil {
- return NIL, e
+ return nil, e
}
tx, err = ParseZoneinfo(data);
return tx, err