@@ -42,15 +42,15 @@ const hour_bucket = function(val) {
4242 let date = new Date ( val ) ;
4343 date . setMinutes ( 0 ) ;
4444 date . setSeconds ( 0 ) ;
45- return + date ;
45+ return date ;
4646} ;
4747
4848const day_bucket = function ( val ) {
4949 let date = new Date ( val ) ;
5050 date . setHours ( 0 ) ;
5151 date . setMinutes ( 0 ) ;
5252 date . setSeconds ( 0 ) ;
53- return + date ;
53+ return date ;
5454} ;
5555
5656const week_bucket = function ( val ) {
@@ -61,7 +61,7 @@ const week_bucket = function(val) {
6161 date . setMinutes ( 0 ) ;
6262 date . setSeconds ( 0 ) ;
6363 date . setDate ( diff ) ;
64- return + date ;
64+ return date ;
6565} ;
6666
6767const month_bucket = function ( val ) {
@@ -70,17 +70,17 @@ const month_bucket = function(val) {
7070 date . setMinutes ( 0 ) ;
7171 date . setSeconds ( 0 ) ;
7272 date . setDate ( 1 ) ;
73- return + date ;
73+ return date ;
7474} ;
7575
7676export const COMPUTATIONS = {
77- hour_of_day : new Computation ( "hour_of_day" , "date " , "integer" , hour_of_day ) ,
78- day_of_week : new Computation ( "day_of_week" , "date " , "string" , day_of_week ) ,
79- month_of_year : new Computation ( "month_of_year" , "date " , "string" , month_of_year ) ,
80- hour_bucket : new Computation ( "hour_bucket" , "date " , "date " , hour_bucket ) ,
81- day_bucket : new Computation ( "day_bucket" , "date " , "date" , day_bucket ) ,
82- week_bucket : new Computation ( "week_bucket" , "date " , "date" , week_bucket ) ,
83- month_bucket : new Computation ( "month_bucket" , "date " , "date" , month_bucket ) ,
77+ hour_of_day : new Computation ( "hour_of_day" , "datetime " , "integer" , hour_of_day ) ,
78+ day_of_week : new Computation ( "day_of_week" , "datetime " , "string" , day_of_week ) ,
79+ month_of_year : new Computation ( "month_of_year" , "datetime " , "string" , month_of_year ) ,
80+ hour_bucket : new Computation ( "hour_bucket" , "datetime " , "datetime " , hour_bucket ) ,
81+ day_bucket : new Computation ( "day_bucket" , "datetime " , "date" , day_bucket ) ,
82+ week_bucket : new Computation ( "week_bucket" , "datetime " , "date" , week_bucket ) ,
83+ month_bucket : new Computation ( "month_bucket" , "datetime " , "date" , month_bucket ) ,
8484 uppercase : new Computation ( "uppercase" , "string" , "string" , x => x . toUpperCase ( ) ) ,
8585 lowercase : new Computation ( "lowercase" , "string" , "string" , x => x . toLowerCase ( ) ) ,
8686 length : new Computation ( "length" , "string" , "integer" , x => x . length ) ,
@@ -107,7 +107,7 @@ class ComputedColumn extends HTMLElement {
107107 integer : "123" ,
108108 string : "abc" ,
109109 boolean : "t/f" ,
110- date : "mdy"
110+ datetime : "mdy"
111111 } ;
112112 }
113113
@@ -329,7 +329,11 @@ class ComputedColumn extends HTMLElement {
329329
330330 const index = Number . parseInt ( target . getAttribute ( "data-index" ) ) ;
331331
332- if ( ( computation_type !== "float" && type !== computation_type ) || ( computation_type === "float" && type !== "float" && type !== "integer" ) ) {
332+ if (
333+ ( computation_type !== "float" && computation_type !== "datetime" && type !== computation_type ) ||
334+ ( computation_type === "float" && type !== "float" && type !== "integer" ) ||
335+ ( computation_type === "datetime" && type !== "datetime" && type !== "date" )
336+ ) {
333337 this . _register_inputs ( ) ;
334338 this . state . errors . input_column = `Input column type (${ type } ) must match computation input type (${ computation_type } ).` ;
335339 this . _set_error_message ( "input_column" , this . _input_column_error_message ) ;
0 commit comments