mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
sql datasource: extract common logic for converting time column to epoch time in ms
This commit is contained in:
@@ -88,3 +88,13 @@ func (tr *TimeRange) ParseTo() (time.Time, error) {
|
||||
|
||||
return time.Time{}, fmt.Errorf("cannot parse to value %s", tr.To)
|
||||
}
|
||||
|
||||
// EpochPrecisionToMs converts epoch precision to millisecond, if needed.
|
||||
// Only seconds to milliseconds supported right now
|
||||
func EpochPrecisionToMs(value float64) float64 {
|
||||
if int64(value)/1e10 == 0 {
|
||||
return float64(value * 1e3)
|
||||
}
|
||||
|
||||
return float64(value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user