DateTime library

415 views
Skip to first unread message

Kalpesh Rathod

unread,
May 31, 2016, 6:14:10 PM5/31/16
to Blockly
How can you integrate DataTime Library in blockly ?

Same as math ?

for example i want to compare DateTime.Today == "1-Jun-2016"

and many more 


Thanks
Kalpesh

Daaron Dwyer

unread,
May 31, 2016, 6:41:20 PM5/31/16
to Blockly
Yes, it's much the same as any other function. You have to decide the inputs (whether you enter the full date, whether it's parsed, etc), do your actual function, then return some value.

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Neil Fraser

unread,
May 31, 2016, 6:42:29 PM5/31/16
to blo...@googlegroups.com
You will need to design and build a bunch of blocks to correspond with the date/time API you wish to expose.  You didn't specify which language you are looking at, but for argument's sake if we look at Python there are hundreds of properties and methods:
https://docs.python.org/2/library/datetime.html
So unless you want to create hundreds of new block types, the first thing you'll need to do is come up with a reduced API that you wish to expose and design the necessary blocks.

Once you figure out what you need, then use the Block Factory to build these blocks.  I'd recommend using the hidden FieldDate input type that's currently commented out for size reasons.  Uncomment line 37 in core/blockly.js and run the build script.  Then also uncomment FieldDate on line 202 in demos/blockfactory/index.html.

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kalpesh Rathod

unread,
Jun 8, 2016, 2:39:06 PM6/8/16
to Blockly
Thanks Neil. I was taking to javascript.

I want to develop block for Date..for Example .. DateTime.Today() is one block.

I want to do DateTime.AddDays(), Datetime.Compare,Datetime.Subtract , Extract Month , Year from Date as well ..kind of all manipulation with date. 

Let me know if somebody develop any DateTime library same as Math. 

I use lot of condition for example If  "06-June-2016" == Today ? do the following process

Thanks

Daaron Dwyer

unread,
Jun 8, 2016, 2:40:30 PM6/8/16
to Blockly
I highly recommend the Moment.js library: http://momentjs.com/

--
Reply all
Reply to author
Forward
0 new messages