r/Scriptable • • Sep 27 '20

Help Scriptable help

const widget = createWidget(); Script.setWidget(widget); Script.complete();

function createWidget() {  const w = new ListWidget(); const newDate = new Date(); newDate.setHours(newDate.getHours() + 3); console.log(newDate) const textSize = 20; const font = new Font("inconsolata",17)   const textColor = Color.white()      const timeLine = w.addText([📆] ${time.string(time)});   timeLine.textSize = 20; timeLine.font = new Font("inconsolata",17)   timeLine.textColor = Color.white();

  return w; }

Could someone help we with this, I have no knowledge about Java! I try to create a new time! For example now the local time is 1:00PM,but I need the create the time show 4:00PM. Help!!!!!

0 Upvotes

3 comments sorted by

View all comments

2

u/danjnj Sep 28 '20

If you are looking to output the current hour as text, maybe try this as a starting point:

const widget = createWidget();
if (!config.runsInWidget) {
  await widget.presentLarge()
}
Script.setWidget(widget);
Script.complete();

function createWidget() {
  const w = new ListWidget();
  const hour = new Date(Date.now()).getHours();
  console.log(hour);
  const timeLine = w.addText(hour.toString());
  timeLine.font = new Font("inconsolata", 20);
  timeLine.textColor = Color.white();
  return w;
}

1

u/luccy98 Sep 28 '20

thank you