Login
server-time.fossi1ish at [0ab8c75c49]
Login

File th1ish/cgi/widgets/server-time.fossi1ish artifact b9f4fa9522 part of check-in 0ab8c75c49


/**
  A demonstration widget which outputs the server-reported time.
*/
$function(){
    // argv.0 === the widget's name
    // argv.1 === the rendering options. Frameworks always passes an Object if the client does not.

    // Set defaults for options client did not provide:
    const opt = this.extendProperties(object{
        localTime: false,
        timeFormat: "%Y-%m-%d %H:%M:%S",
        tzLabel: false
    }, argv.1 )

    // Generate the output:
    opt.label && $this.out opt.label ' '
    $this.out strftime(opt.timeFormat, -1, opt.localTime)
    opt.tzLabel && $this.out opt.localTime ? ' local' : ' UTC'

}.apply api.cgi api.cgi.renderWidget.renderArgs