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

datetime Evaluation error: argument 0 with type int64 but it should be float64 #72

Closed
den-vasyliev opened this issue Feb 26, 2018 · 6 comments

Comments

@den-vasyliev
Copy link

Great plugin - thanks a lot!

Minor:
http://plugins.drone.io/drone-plugins/drone-slack/
Issue:
"datetime
converts a unix timestamp to a date time string. Example {{datetime build.started}}"
But

  1. Should be e.g. started: {{datetime 1519654914.0 "Mon Jan _2 15:04:05 2006" "EET"}}
  2. "Evaluation error: Helper datetime called with argument 0 with type int64 but it should be float64"
    template.go - 90: func toDatetime(timestamp float64, layout, zone string) string
    main.go - 185: Started: c.Int64("build.started"),
    plugin.go - 29: Started int64

Thank you.

@bradrydzewski
Copy link
Member

you can use the datetime function to convert to a human-friendly date. For example {{datetime build.started}}

@den-vasyliev
Copy link
Author

Yes i can but its not worked for me. And why i mentioned before.

@bradrydzewski
Copy link
Member

bradrydzewski commented Feb 26, 2018

If you continue to experience issues please send a patch

@den-vasyliev
Copy link
Author

Thank you!

Done:

diff --git a/template.go b/template.go
index 1f9c0ec..fd62990 100644
--- a/template.go
+++ b/template.go
@@ -87,7 +87,7 @@ func toDuration(started, finished float64) string {
return fmt.Sprintln(time.Duration(finished-started) * time.Second)
}

-func toDatetime(timestamp float64, layout, zone string) string {
+func toDatetime(timestamp int64, layout, zone string) string {
if len(zone) == 0 {
return time.Unix(int64(timestamp), 0).Format(layout)
}

Tests done with denvasyliev/slack.

Fixed issue:
screen shot 2018-02-26 at 18 49 43

Need to fix documentation http://plugins.drone.io/drone-plugins/drone-slack/:

  • converts a unix timestamp to a date time string. Example {{datetime build.started}}
    +converts a unix timestamp to a date time string. Example {{datetime build.started "Mon Jan _2 15:04:05 2006" "EET"}}

Works fine for first look :)

@waterdrop01
Copy link

I have the exact same issue, described here: #106 (comment)

@ErvalhouS
Copy link

Similar issue to #123 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants