UBotBuddy 331 Posted July 23, 2014 Report Share Posted July 23, 2014 Recently I needed the "Day of the Week". Yes, I could have used the javascript path to get this but then I got to thinking that this might be a great learning bot for those that do not care for javascript.This bot will show you several things such using the Define node for a function as well as some Regex items.There are a few other coding shortcuts in here so study the bot carefully.If you like this bot then please throw a "Like" my way.Buddy DayOfTheWeek.ubot The code for you Cut & Pasting people. set(#myDate, $trim($substring($date, 0, 10)), "Global") set(#DayOfTheWeek, $DOW(#myDate), "Global") define $DOW(#myDate) { loop(1) { set(#year, $substring(#myDate, 6, 4), "Global") set(#result, $divide(#year, 4), "Global") if($comparison($text length(#result), ">", 3)) { then { set(#MonthsData, "0,3,3,6,1,4,6,2,5,0,3,5", "Global") } else { set(#MonthsData, "6,2,3,6,1,4,6,2,5,0,3,5", "Global") } } clear list(%MonthsTable) add list to list(%MonthsTable, $list from text(#MonthsData, ","), "Don\'t Delete", "Global") clear list(%DaysTable) add list to list(%DaysTable, $list from text("Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday", ","), "Delete", "Global") } set(#d, $replace regular expression(#myDate, "(\\d\{1,\})\\/(\\d\{1,\})\\/20(\\d\{1,\})", "$1"), "Global") set(#m, $replace regular expression(#myDate, "(\\d\{1,\})\\/(\\d\{1,\})\\/20(\\d\{1,\})", "$2"), "Global") set(#y, $replace regular expression(#myDate, "(\\d\{1,\})\\/(\\d\{1,\})\\/20(\\d\{1,\})", "$1"), "Global") set(#result, $eval("({#d}+{#m}+{#y}+{$eval("Math.floor({#y}/4)")}+6) % 7"), "Global") set(#result, $list item(%DaysTable, #result), "Global") clear list(%DaysTable) clear list(%MonthsTable) set(#MonthsData, $nothing, "Global") set(#d, $nothing, "Global") set(#m, $nothing, "Global") set(#y, $nothing, "Global") set(#year, $nothing, "Global") return(#result) } 2 Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted July 23, 2014 Report Share Posted July 23, 2014 Thanks Buddy, pretty cool, With all due respect, here is a free plugin that ubotdev.com @ ubotdev.com that makes this soo much easier. At least for me anyways. Date and Time Manipulation the code comment("Be sure to hit the \"\" buttonas not to divide your date")set(#input_date, "07/24/2014", "Global")set(#result_abbreviated_DOW, $plugin function("DateTime Manipulation.dll", "$datetime manipulation", #input_date, "MM/dd/yyyy", "ddd", "en-US", "en-US"), "Global")set(#result_long_DOW, $replace regular expression($plugin function("DateTime Manipulation.dll", "$datetime manipulation", #input_date, "MM/dd/yyyy", "Universal full date/time", "en-US", "en-US"), ",.*,.*", $nothing), "Global")alert("Abbreviated {#result_abbreviated_DOW}Long {#result_long_DOW}") Knowledge is power, eh? Regards,TC 1 Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted July 23, 2014 Report Share Posted July 23, 2014 All great ways above, and great job guys. My way http://content.screencast.com/users/lowridertj/folders/Ubot%20Studio%20Plugins/media/8fd8408e-a3b6-45ae-ba9a-09af03555c14/07.23.2014-18.png Quote Link to post Share on other sites
runsoftware 14 Posted July 23, 2014 Report Share Posted July 23, 2014 All great ways above, and great job guys. My way http://content.screencast.com/users/lowridertj/folders/Ubot%20Studio%20Plugins/media/8fd8408e-a3b6-45ae-ba9a-09af03555c14/07.23.2014-18.pngtoo complicated Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted July 23, 2014 Report Share Posted July 23, 2014 That's all good for the "current day" Tj, but....but.... can you get it for any day? like 07/24/3000 or just next months 08/24/2014? In any format? all depends on one's needs TC Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted July 24, 2014 Report Share Posted July 24, 2014 That's all good for the "current day" Tj, but....but.... can you get it for any day? like 07/24/3000 or just next months 08/24/2014? In any format? all depends on one's needs TC See functions on the left, you can format it any way you like.and calculates the number of days for current, previous month on auto to be as precise as you want to be with it. Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted July 24, 2014 Report Share Posted July 24, 2014 I think I have that plugin but I didn't update so I don't have those functions. Since you pointed out I see now. Is that the same time.dll I have? Imma go look yeah, I'm talking about this one http://www.ubotstudio.com/forum/index.php?/topic/13550-free-plugin-time-plugin-make-your-own-scheduler/ Quote Link to post Share on other sites
UBotBuddy 331 Posted July 24, 2014 Author Report Share Posted July 24, 2014 I knew about the plugins but I am all about the coding side of the fence. LOL Geeezz TZ do you start up your UBot on Sunday and wait until Tuesday for it to load all of your plugins? The three plugins that I use the most makes my UBot start up time to REALLY drag out. LOL Life in the fast lane. Gotta love it. Buddy Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted July 24, 2014 Report Share Posted July 24, 2014 the above functions aren't released anywhere as of yet, was trying to reach the original developer for him to be able to release them. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.