@rob, If you would like to get rid of the leading zero, JavaScript is your friend:
('0'+minutes).slice(-2)
See my widget as well (lines 159 and following).
@rob, If you would like to get rid of the leading zero, JavaScript is your friend:
('0'+minutes).slice(-2)
See my widget as well (lines 159 and following).
Can you please explain that code?
I think it takes care of adding a leading zero, not removing it?
Yes, it adds a leading zero. Did I understand you wrong? Try it on your browser console, for example:
new Date().getMinutes().toString().slice(-2)
or even simpler:
('0'+"02").slice(-2)
// "02"
Did I understand you wrong?
Looks like that; I want “7:24” instead of “07:24” (remove the trailing zero from the hours).
toLocaleTimeString should do this when using option “numeric” (instead of “2-digit”), but I still get the leading zero (bug in Scriptable/iOS?).
There’s a DateFormatter object in Scriptable that you could use.
Do you format the hour and minute separately? It looks kind of weird like this. I’d go for “7:15” and “17:15”, no leading space. Then right align by putting a spacer in front.
However, digits in this font differ in width, I believe. So the result might still be a bit in jagged.
Do you format the hour and minute separately?
Yes, in an attempt to align the colons…
(and to use a slightly less bright color for the colons)
Because the font is proportional, I think that you would have to treat each digit (converting leading zeros to nothing/spaces) as a separate element and align them centrally in each column to have each digit align with the corresponding digit vertically.
So for an “hh:mm” format, that would be five characters and so five columns.
If you could switch to a fixed width font, then three columns for the time, due to the difference in the colon colouration, should be sufficient.
Right, it should be possible to use a monospaced font like so
label.font = new Font("Courier", 18);
// @see http://iosfonts.com
Courier is really ugly.
And traditionally, many fonts used equal-width digits exactly to make them fit for purpose in tabular environments:
Using Helvetica Neue (and keeping the trailing zero for hours) it looks better indeed!
If I could find a way to properly align the SF symbols with the text I would call it done.
Hey eqsOne,
thanks for trying :).
BR
gentlel
This is a pretty silly question, but has anyone managed to put a border around a widget, like in WidgetSmith? I’m trying this, but without any luck:
let widget = new ListWidget()
widget.backgroundColor = Color.white()
widget.borderWidth = 8
widget.borderColor = Color.black()
based on the documentation, ListWidget doesn’t have any border-related properties & methods, it’s the WidgetStack that has those.
Where do you define the variable utcTime
?
These are the 2 only lines containing the variable utcTime
// In the 30min before/after, use dawn/twilight.
if (closeTo(sunrise)<=45 && utcTime < sunrise) { return gradient.dawn }
if (closeTo(sunset)<=45 && utcTime > sunset) { return gradient.twilight }
So maybe it is not declared earlier.
It is a modified version of this https://github.com/mzeryck/Weather-Cal/blob/12458704822c67017ff9f83e6ab5530371a6f75a/weather-cal.js from @mzeryck
Ist es möglich, auch auf die Termine des calendars 5 zuzugreifen
Ich benötige diese Kalender App da man hier Outlook.com einbinden kann. Dein wether Widget ist einfach genial und ich kopiere bisher extra die Termine in Apple Kalender.
Eine direkte Integration wäre natürlich viel einfacher für mich