Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove monoclock & add tz as chain param #3193

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ab4c8a7
feat: new time pkg version to be handled by r/sys/params
MikaelVallenet Nov 25, 2024
8044c1c
feat: remove location usage in time.Date function
MikaelVallenet Nov 25, 2024
192bef8
feat: rename internal to abs
MikaelVallenet Nov 25, 2024
95ea22e
tests: fix time pkg test
MikaelVallenet Nov 25, 2024
750f5b8
feat: add chain tz as a param
MikaelVallenet Nov 25, 2024
e46c332
feat: include chain tz in exec context of gno machine
MikaelVallenet Nov 25, 2024
5b8aeec
feat: include a getter chain tz in stdlib
MikaelVallenet Nov 25, 2024
41c5f31
feat: generate go native injection
MikaelVallenet Nov 25, 2024
67cf3eb
feat: add function to retrive param from sys realm
MikaelVallenet Nov 25, 2024
a025451
feat: wip
MikaelVallenet Nov 25, 2024
3e0601e
feat: wip
MikaelVallenet Nov 26, 2024
9b2bf1f
test: add unit test about tz as a chain param
MikaelVallenet Nov 26, 2024
2857864
test: add unit test about tz as a chain param
MikaelVallenet Nov 26, 2024
0e2df05
feat: merge master
MikaelVallenet Nov 27, 2024
cc2bbe1
test: fix add UTC default on creating testing node config
MikaelVallenet Nov 27, 2024
c3ecc97
feat: add tz param in gnodev genesis
MikaelVallenet Nov 28, 2024
ed8b686
feat: refactor to follow manfred's comment
MikaelVallenet Dec 26, 2024
19f2ee8
feat: merge master
MikaelVallenet Dec 26, 2024
347d9ac
feat: merge master
MikaelVallenet Dec 26, 2024
35808d6
chore: generate
MikaelVallenet Dec 26, 2024
9e0f8d1
fix: pkg time
MikaelVallenet Dec 26, 2024
516fa88
fix: pkg time
MikaelVallenet Dec 26, 2024
af8f014
fix: remove timetest
MikaelVallenet Dec 26, 2024
b46af3b
fix: test
MikaelVallenet Dec 26, 2024
52debc7
fix: test
MikaelVallenet Dec 27, 2024
b063cb6
Merge branch 'master' into dev/mikaelvallenet/feat/time-remove-mono-a…
MikaelVallenet Dec 27, 2024
a4335a8
Merge branch 'master' into dev/mikaelvallenet/feat/time-remove-mono-a…
MikaelVallenet Dec 30, 2024
36579ff
docs: small fix
MikaelVallenet Dec 30, 2024
b4e0b10
docs: small fix
MikaelVallenet Dec 30, 2024
b856c78
docs: small fix
MikaelVallenet Dec 30, 2024
487ed42
std(time): fix add duration function with updating nano seconds too
MikaelVallenet Dec 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 10 additions & 39 deletions examples/gno.land/r/demo/boards/z_4_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -309,36 +309,16 @@ func main() {
// c[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:131]={
// "Fields": [
// {
// "N": "AAAAgJSeXbo=",
// "T": {
// "@type": "/gno.PrimitiveType",
// "value": "65536"
// }
// },
// {
// "N": "AbSNdvQQIhE=",
// "N": "0vknwQ4AAAA=",
// "T": {
// "@type": "/gno.PrimitiveType",
// "value": "1024"
// }
// },
// {
// "T": {
// "@type": "/gno.PointerType",
// "Elt": {
// "@type": "/gno.RefType",
// "ID": "time.Location"
// }
// },
// "V": {
// "@type": "/gno.PointerValue",
// "Base": {
// "@type": "/gno.RefValue",
// "Escaped": true,
// "ObjectID": "336074805fc853987abe6f7fe3ad97a6a6f3077a:2"
// },
// "Index": "182",
// "TV": null
// "@type": "/gno.PrimitiveType",
// "value": "512"
// }
// }
// ],
Expand All @@ -354,22 +334,13 @@ func main() {
// {
// "T": {
// "@type": "/gno.PrimitiveType",
// "value": "65536"
// }
// },
// {
// "T": {
// "@type": "/gno.PrimitiveType",
// "value": "1024"
// }
// },
// {
// "T": {
// "@type": "/gno.PointerType",
// "Elt": {
// "@type": "/gno.RefType",
// "ID": "time.Location"
// }
// "@type": "/gno.PrimitiveType",
// "value": "512"
// }
// }
// ],
Expand Down Expand Up @@ -498,7 +469,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "0fd3352422af0a56a77ef2c9e88f479054e3d51f",
// "Hash": "55cc9b7009f66b35f15d34ceed3fa25c9e36d54d",
// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:131"
// }
// },
Expand All @@ -509,7 +480,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "bed4afa8ffdbbf775451c947fc68b27a345ce32a",
// "Hash": "d8d66a5855b0427c262cfce9891c88d469ab2351",
// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:132"
// }
// }
Expand All @@ -535,7 +506,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "c45bbd47a46681a63af973db0ec2180922e4a8ae",
// "Hash": "6b2cd34f216499f59540555be3fe11f40a67baa1",
// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:127"
// }
// }
Expand Down Expand Up @@ -786,7 +757,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "a416a751c3a45a1e5cba11e737c51340b081e372",
// "Hash": "ed9d8105a90a05bc8d953538dd8810201e26ec6d",
// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:86"
// }
// },
Expand All @@ -804,7 +775,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "36299fccbc13f2a84c4629fad4cb940f0bd4b1c6",
// "Hash": "ef78d14dccddfaa802727058e543d3ecc87157f0",
// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:87"
// }
// },
Expand Down
4 changes: 2 additions & 2 deletions examples/gno.land/r/demo/groups/z_1_a_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ func main() {
//
// Group Creator: gnouser0
//
// Group createdAt: 2009-02-13 23:31:30 +0000 UTC m=+1234567890.000000001
// Group createdAt: 2009-02-13 23:31:30 +0000 UTC
//
// Group Last MemberID: 0000000001
//
// Group Members:
//
// [0000000000, g1vahx7atnv4erxh6lta047h6lta047h6ll85gpy, 32, i am from UAE, 2009-02-13 23:31:30 +0000 UTC m=+1234567890.000000001],
// [0000000000, g1vahx7atnv4erxh6lta047h6lta047h6ll85gpy, 32, i am from UAE, 2009-02-13 23:31:30 +0000 UTC],
//
//
2 changes: 1 addition & 1 deletion examples/gno.land/r/demo/groups/z_2_a_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func main() {
//
// Group Creator: gnouser0
//
// Group createdAt: 2009-02-13 23:31:30 +0000 UTC m=+1234567890.000000001
// Group createdAt: 2009-02-13 23:31:30 +0000 UTC
//
// Group Last MemberID: 0000000001
//
Expand Down
6 changes: 0 additions & 6 deletions examples/gno.land/r/gnoland/events/events.gno
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,5 @@ func parseTimes(startTime, endTime string) (time.Time, time.Time, error) {
return time.Time{}, time.Time{}, ErrEndBeforeStart
}

_, stOffset := st.Zone()
_, etOffset := et.Zone()
if stOffset != etOffset {
return time.Time{}, time.Time{}, ErrStartEndTimezonemMismatch
}

return st, et, nil
}
3 changes: 0 additions & 3 deletions examples/gno.land/r/gnoland/events/events_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@ func TestParseTimes(t *testing.T) {

_, _, err = parseTimes("2009-02-13T23:30:30Z", "2009-02-13T21:30:30Z")
uassert.ErrorContains(t, err, ErrEndBeforeStart.Error())

_, _, err = parseTimes("2009-02-10T23:30:30+02:00", "2009-02-13T21:30:33+05:00")
uassert.ErrorContains(t, err, ErrStartEndTimezonemMismatch.Error())
}

func TestRenderEventWidget(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions examples/gno.land/r/gnoland/monit/monit_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ status=KO`
Incr()
{
expected := `counter=3
last update=2009-02-13 23:31:30 +0000 UTC m=+1234567890.000000001
last update=2009-02-13 23:31:30 +0000 UTC
last caller=g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
status=OK`
got := Render("")
Expand All @@ -35,7 +35,7 @@ status=OK`
use std.TestSkipTime(time.Hour)
{
expected := `counter=3
last update=2009-02-13 22:31:30 +0000 UTC m=+1234564290.000000001
last update=2009-02-13 22:31:30 +0000 UTC
last caller=g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
status=KO`
got := Render("")
Expand All @@ -46,7 +46,7 @@ status=OK`
Incr()
{
expected := `counter=4
last update=2009-02-13 23:31:30 +0000 UTC m=+1234567890.000000001
last update=2009-02-13 23:31:30 +0000 UTC
last caller=g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
status=OK`
got := Render("")
Expand Down
32 changes: 1 addition & 31 deletions gnovm/stdlibs/time/format.gno
Original file line number Diff line number Diff line change
Expand Up @@ -510,30 +510,6 @@ func formatNano(b []byte, nanosec uint, std int) []byte {
// with an explicit format string.
func (t Time) String() string {
s := t.Format("2006-01-02 15:04:05.999999999 -0700 MST")

// Format monotonic clock reading as m=±ddd.nnnnnnnnn.
if t.wall&hasMonotonic != 0 {
m2 := uint64(t.ext)
sign := byte('+')
if t.ext < 0 {
sign = '-'
m2 = -m2
}
m1, m2 := m2/1e9, m2%1e9
m0, m1 := m1/1e9, m1%1e9
buf := make([]byte, 0, 24)
buf = append(buf, " m="...)
buf = append(buf, sign)
wid := 0
if m0 != 0 {
buf = appendInt(buf, int(m0), 0)
wid = 9
}
buf = appendInt(buf, int(m1), wid)
buf = append(buf, '.')
buf = appendInt(buf, int(m2), 9)
s += string(buf)
}
return s
}

Expand Down Expand Up @@ -566,8 +542,6 @@ func (t Time) GoString() string {
switch loc := t.Location(); loc {
case UTC, nil:
buf = append(buf, "time.UTC"...)
case Local:
buf = append(buf, "time.Local"...)
default:
// there are several options for how we could display this, none of
// which are great:
Expand Down Expand Up @@ -959,7 +933,7 @@ func skip(value, prefix string) (string, error) {
// differ by the actual zone offset. To avoid such problems, prefer time layouts
// that use a numeric zone offset, or use ParseInLocation.
func Parse(layout, value string) (Time, error) {
return parse(layout, value, UTC, Local)
return parse(layout, value, UTC, ChainTZ)
}

// ParseInLocation is like Parse but differs in two important ways.
Expand Down Expand Up @@ -1301,12 +1275,10 @@ func parse(layout, value string, defaultLocation, local *Location) (Time, error)
// If that zone was in effect at the given time, use it.
name, offset, _, _, _ := local.lookup(t.unixSec())
if offset == zoneOffset && (zoneName == "" || name == zoneName) {
t.setLoc(local)
return t, nil
}

// Otherwise create fake zone to record offset.
t.setLoc(FixedZone(zoneName, zoneOffset))
return t, nil
}

Expand All @@ -1317,7 +1289,6 @@ func parse(layout, value string, defaultLocation, local *Location) (Time, error)
offset, ok := local.lookupName(zoneName, t.unixSec())
if ok {
t.addSec(-int64(offset))
t.setLoc(local)
return t, nil
}

Expand All @@ -1326,7 +1297,6 @@ func parse(layout, value string, defaultLocation, local *Location) (Time, error)
offset, _ = atoi(zoneName[3:]) // Guaranteed OK by parseGMT.
offset *= 3600
}
t.setLoc(FixedZone(zoneName, offset))
return t, nil
}

Expand Down
Loading
Loading