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

make epoch time for mainnet more intuitive #6961

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions cli/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ func parseTipSet(ctx context.Context, api v0api.FullNode, vals []string) (*types
}

func EpochTime(curr, e abi.ChainEpoch) string {
if build.BuildType == build.BuildMainnet {
start := time.Date(2020, 8, 24, 22, 0, 0, 0, time.UTC)
eTime := start.Add(time.Second * time.Duration(int64(build.BlockDelaySecs)*int64(e)))
return fmt.Sprintf("%d (%s)", e, eTime.Format("2006-01-02 15:04 MST"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zlhwdsz I think the notion of relative time is actually more intuitive than including the timestamp. I can see the timestamp helping though so I'll approve if you print both for mainnet Epoch time: (%d, %s ([now | %s ago | in %s]))

Copy link
Contributor Author

@zlhwdsz zlhwdsz Aug 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way the check-expire lines will be lengthy and hard to read:

df95d151fec0ddc5f50173edc16d5cf

I closed this PR and provide a customized epochTime function for check-expire cmd in #7101 .

}

switch {
case curr > e:
return fmt.Sprintf("%d (%s ago)", e, durafmt.Parse(time.Second*time.Duration(int64(build.BlockDelaySecs)*int64(curr-e))).LimitFirstN(2))
Expand Down