Others smarter than me may have a better way of going about this, but here are some answers.
Basically what you have to do is give this code a context where it runs. This context needs data being evaluating and a field in the UI that is being updated. The easiest way to do that is by dragging a standard salesforce field onto your page and then building a custom Field Renderer for it.
I used the create date field.
Then you create snippets. I took what you provided and broke them out of the functions so they run more directly. .
Here is the current quarter:
var $ = skuid.$, field = arguments=0],<br> date = arguments=1],<br> jsdate = skuid.time.parseSFDate(date)|| new Date(); // If no date supplied, use today<br> var q = p1,2,3,4];<br>// quarter definition: 1: Jan - Mar 2: Apr - Jun 3: Jul - Sep 4: Oct - Dec <br> <br> var newValue=q Math.floor(jsdate.getMonth() / 3)];<br>//console.log (jsdate,newValue);<br>skuid.ui.fieldRenderers.TEXTdfield.mode](field, newValue);<br>
Quarter definition threw me for a loop until I found the original stack exchange post where you got the code. The definition used there was US Goft fiscal year where Q1 = October - December… DOH
Then:
Here is days remaining in quarter:
var $ = skuid.$,field = argumentsi0],<br>date = new Date();<br>var qEnd = new Date(date);<br>qEnd.setMonth(qEnd.getMonth() + 3 - qEnd.getMonth() % 3, 0);<br>var newValue = Math.floor((qEnd - date) / 8.64e7);<br>//console.log (qEnd,newValue);<br>skuid.ui.fieldRenderers.TEXTlfield.mode](field, newValue);
Enjoy!
Thank you Rob! I will give a go and report back.