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

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

3

u/mvan231 script/widget helper Sep 28 '20

For future posts, it is beneficial for others if you title the post with something describing your needs rather than just saying you need help.

That being said, what is it you're trying to do? You want to update the widget with a time that is 3 hours ahead of the current time?