Short names of some date related functions

This commit is contained in:
Brian Brazil 2016-08-23 22:34:22 +01:00
parent d2ca2b496a
commit ea1318f38b
2 changed files with 14 additions and 14 deletions

View file

@ -892,8 +892,8 @@ func funcDayOfWeek(ev *evaluator, args Expressions) model.Value {
return vector return vector
} }
// === hour_of_day(v vector) scalar === // === hour(v vector) scalar ===
func funcHourOfDay(ev *evaluator, args Expressions) model.Value { func funcHour(ev *evaluator, args Expressions) model.Value {
vector := ev.evalVector(args[0]) vector := ev.evalVector(args[0])
for _, el := range vector { for _, el := range vector {
el.Metric.Del(model.MetricNameLabel) el.Metric.Del(model.MetricNameLabel)
@ -902,8 +902,8 @@ func funcHourOfDay(ev *evaluator, args Expressions) model.Value {
return vector return vector
} }
// === month_of_year(v vector) scalar === // === month(v vector) scalar ===
func funcMonthOfYear(ev *evaluator, args Expressions) model.Value { func funcMonth(ev *evaluator, args Expressions) model.Value {
vector := ev.evalVector(args[0]) vector := ev.evalVector(args[0])
for _, el := range vector { for _, el := range vector {
el.Metric.Del(model.MetricNameLabel) el.Metric.Del(model.MetricNameLabel)
@ -1037,11 +1037,11 @@ var functions = map[string]*Function{
ReturnType: model.ValVector, ReturnType: model.ValVector,
Call: funcHoltWinters, Call: funcHoltWinters,
}, },
"hour_of_day": { "hour": {
Name: "hour_of_day", Name: "hour",
ArgTypes: []model.ValueType{model.ValVector}, ArgTypes: []model.ValueType{model.ValVector},
ReturnType: model.ValVector, ReturnType: model.ValVector,
Call: funcHourOfDay, Call: funcHour,
}, },
"idelta": { "idelta": {
Name: "idelta", Name: "idelta",
@ -1097,11 +1097,11 @@ var functions = map[string]*Function{
ReturnType: model.ValVector, ReturnType: model.ValVector,
Call: funcMinOverTime, Call: funcMinOverTime,
}, },
"month_of_year": { "month": {
Name: "month_of_year", Name: "month",
ArgTypes: []model.ValueType{model.ValVector}, ArgTypes: []model.ValueType{model.ValVector},
ReturnType: model.ValVector, ReturnType: model.ValVector,
Call: funcMonthOfYear, Call: funcMonth,
}, },
"predict_linear": { "predict_linear": {
Name: "predict_linear", Name: "predict_linear",

View file

@ -370,7 +370,7 @@ clear
eval instant at 0m year(vector(0)) eval instant at 0m year(vector(0))
{} 1970 {} 1970
eval instant at 0m month_of_year(vector(0)) eval instant at 0m month(vector(0))
{} 1 {} 1
eval instant at 0m day_of_month(vector(0)) eval instant at 0m day_of_month(vector(0))
@ -380,7 +380,7 @@ eval instant at 0m day_of_month(vector(0))
eval instant at 0m day_of_week(vector(0)) eval instant at 0m day_of_week(vector(0))
{} 4 {} 4
eval instant at 0m hour_of_day(vector(0)) eval instant at 0m hour(vector(0))
{} 0 {} 0
# 2008-12-31 23:59:59 just before leap second. # 2008-12-31 23:59:59 just before leap second.
@ -392,11 +392,11 @@ eval instant at 0m year(vector(1230768000))
{} 2009 {} 2009
# 2016-02-29 23:59:59 Febuary 29th in leap year. # 2016-02-29 23:59:59 Febuary 29th in leap year.
eval instant at 0m month_of_year(vector(1456790399)) + day_of_month(vector(1456790399)) / 100 eval instant at 0m month(vector(1456790399)) + day_of_month(vector(1456790399)) / 100
{} 2.29 {} 2.29
# 2016-03-01 00:00:00 March 1st in leap year. # 2016-03-01 00:00:00 March 1st in leap year.
eval instant at 0m month_of_year(vector(1456790400)) + day_of_month(vector(1456790400)) / 100 eval instant at 0m month(vector(1456790400)) + day_of_month(vector(1456790400)) / 100
{} 3.01 {} 3.01
# Febuary 1st 2016 in leap year. # Febuary 1st 2016 in leap year.