Better naming

This commit is contained in:
Miek Gieben 2012-09-11 21:45:21 +02:00
parent e70e40095b
commit 915781ea86
4 changed files with 15 additions and 15 deletions

View File

@ -521,8 +521,8 @@ func TestRfc1982(t *testing.T) {
// fall in the current 68 year span
strtests := []string{"20120525134203", "19700101000000", "20380119031408"}
for _, v := range strtests {
if x, _ := DateToTime(v); v != TimeToDate(x) {
t.Logf("1982 arithmetic string failure %s (%s:%d)", v, TimeToDate(x), x)
if x, _ := DateToTime(v); v != TimeToString(x) {
t.Logf("1982 arithmetic string failure %s (%s:%d)", v, TimeToString(x), x)
t.Fail()
}
}
@ -532,8 +532,8 @@ func TestRfc1982(t *testing.T) {
1<<32 - 1: "21060207062815",
}
for i, v := range inttests {
if TimeToDate(i) != v {
t.Logf("1982 arithmetic int failure %d:%s (%s)", i, v, TimeToDate(i))
if TimeToString(i) != v {
t.Logf("1982 arithmetic int failure %d:%s (%s)", i, v, TimeToString(i))
t.Fail()
}
}
@ -549,7 +549,7 @@ func TestRfc1982(t *testing.T) {
}
for from, to := range future {
x, _ := DateToTime(from)
y := TimeToDate(x)
y := TimeToString(x)
if y != to {
t.Logf("1982 arithmetic future failure %s:%s (%s)", from, to, y)
t.Fail()

View File

@ -95,7 +95,7 @@ func (rr *RR_TSIG) String() string {
s := "\n;; TSIG PSEUDOSECTION:\n"
s += rr.Hdr.String() +
" " + rr.Algorithm +
" " + tsigTimeToDate(rr.TimeSigned) +
" " + tsigTimeToString(rr.TimeSigned) +
" " + strconv.Itoa(int(rr.Fudge)) +
" " + strconv.Itoa(int(rr.MACSize)) +
" " + strings.ToUpper(rr.MAC) +
@ -351,7 +351,7 @@ func stripTsig(msg []byte) ([]byte, *RR_TSIG, error) {
// Translate the TSIG time signed into a date. There is no
// need for RFC1982 calculations as this date is 48 bits.
func tsigTimeToDate(t uint64) string {
func tsigTimeToString(t uint64) string {
ti := time.Unix(int64(t), 0).UTC()
return ti.Format("20060102150405")
}

View File

@ -844,8 +844,8 @@ func (rr *RR_RRSIG) String() string {
" " + strconv.Itoa(int(rr.Algorithm)) +
" " + strconv.Itoa(int(rr.Labels)) +
" " + strconv.FormatInt(int64(rr.OrigTtl), 10) +
" " + TimeToDate(rr.Expiration) +
" " + TimeToDate(rr.Inception) +
" " + TimeToString(rr.Expiration) +
" " + TimeToString(rr.Inception) +
" " + strconv.Itoa(int(rr.KeyTag)) +
" " + rr.SignerName +
" " + rr.Signature
@ -1371,10 +1371,10 @@ func (rr *RR_WKS) Copy() RR {
return &RR_WKS{*rr.Hdr.CopyHeader(), rr.Address, rr.Protocol, rr.BitMap}
}
// TimeToDate translates the RRSIG's incep. and expir. times to the
// TimeToString translates the RRSIG's incep. and expir. times to the
// string representation used when printing the record.
// It takes serial arithmetic (RFC 1982) into account.
func TimeToDate(t uint32) string {
func TimeToString(t uint32) string {
mod := ((int64(t) - time.Now().Unix()) / year68) - 1
if mod < 0 {
mod = 0
@ -1383,10 +1383,10 @@ func TimeToDate(t uint32) string {
return ti.Format("20060102150405")
}
// DateToTime translates the RRSIG's incep. and expir. times from
// StringToTime translates the RRSIG's incep. and expir. times from
// string values like "20110403154150" to an 32 bit integer.
// It takes serial arithmetic (RFC 1982) into account.
func DateToTime(s string) (uint32, error) {
func StringToTime(s string) (uint32, error) {
t, e := time.Parse("20060102150405", s)
if e != nil {
return 0, e

View File

@ -915,14 +915,14 @@ func setRRSIG(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
<-c // _BLANK
l = <-c
if i, err := DateToTime(l.token); err != nil {
if i, err := StringToTime(l.token); err != nil {
return nil, &ParseError{f, "bad RRSIG Expiration", l}
} else {
rr.Expiration = i
}
<-c // _BLANK
l = <-c
if i, err := DateToTime(l.token); err != nil {
if i, err := StringToTime(l.token); err != nil {
return nil, &ParseError{f, "bad RRSIG Inception", l}
} else {
rr.Inception = i