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,<br> date = arguments,<br> jsdate = skuid.time.parseSFDate(date)|| new Date(); // If no date supplied, use today<br> var q = [1,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.TEXT[field.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
Here is days remaining in quarter:
var $ = skuid.$,field = arguments,<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.TEXT[field.mode](field, newValue);