PDA

View Full Version : Clock Gadgets - Change Time Format



Terrapin2190
April 3rd, 2015, 04:06 AM
I recently installed a few HUD gadgets and realized the clock is stuck in 24-hour/military time for some reason.Anyone know if there's a way to change the time format in the javascript entries?

I poked around a bit in 'C:\Users\[username]\AppData\Local\Microsoft\Windows Sidebar\Gadgets\Airlock Blue Digital Clock.gadget\js' (an easier way to get there is to type 'shell:gadgets' into the start menu search bar), opened the 'clock.js' file by right-click > Edit and noticed there is a line under "Initial Settings" that looks like this:

function view()
{
if (!document.images)
return
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
if ((hours>=00)&&(minutes>=1)||(hours>=13))
{
hours=hours
}
if (hours==0)
hours=12
extract(hours,minutes,seconds)
setTimeout("view()",1000)
}

The hours>=13 and hours=12 gives me something to go on. I'm just getting into learning command lines and VERY basic coding... but hours=12 would make it seem that the clock would display 12-hour mode instead of 24-hour mode. Perhaps I just need a restart for it to display correctly? A nice fresh restart seems to fix a lot of mishaps haha.

YourNumbr1Fan
April 3rd, 2015, 04:24 AM
Try this:

69714



function view()
{
if (!do***ent.images)
return
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
dn = 'AM';
if ((hours >= 12) && (minutes >= 1) || (hours >= 13)) {
dn = 'PM';
hours = hours-12;
}
if (hours == 0)
hours = 12;
extract(hours,minutes,seconds, dn)
setTimeout("view()",1000)
}


Make sure to type in the letters that VC's automated "language robot" replaced with *** symbols!

69716

lmao

Terrapin2190
April 3rd, 2015, 05:47 AM
Hmm... everything looks the same. Y'know, with the exception of censoring haha! I thought it might be the minus sign in front of the 12, but that's the same too. Unless the trigger for 12-hour time resides somewhere else... I still haven't restarted yet though, so we'll see if that does anything... sometime.

Mr GRiM
April 3rd, 2015, 06:48 AM
Sorry guys, I fixed the censoring now so it wont pick up parts of words in other words that don't need to be censored.

YourNumbr1Fan
April 3rd, 2015, 08:17 AM
Sorry guys, I fixed the censoring now so it wont pick up parts of words in other words that don't need to be censored.

That's one DICKens of a censoring software, Mark! Glad you fixed that cirCUMstance! :cheeky:

YourNumbr1Fan
April 3rd, 2015, 08:19 AM
Hmm... everything looks the same. Y'know, with the exception of censoring haha! I thought it might be the minus sign in front of the 12, but that's the same too. Unless the trigger for 12-hour time resides somewhere else... I still haven't restarted yet though, so we'll see if that does anything... sometime.

If you replaced that snippet of code with mine, exit that gadget then apply it anew, it'll show 12-hour time rather than military. Works fine in my gadget.

Terrapin2190
April 3rd, 2015, 10:12 AM
Oh! At first glance I thought that was a quote of my code for some reason. DOH! I'll try it! Thanks!

Now where'd I put that dunce hat?

Terrapin2190
April 3rd, 2015, 10:26 AM
Okay, clock.js uses weird spacing in contrast to yours. I'm editing Airlock HUD digital clock btw.

It used weird spacing, so I went in and edited it manually, sticking to the spacing technique. I copy and pasted what you shared and it showed nothing on the clock. ( :o I broke it! yaaaaay!!!) Looks like it did the trick tho with the spacing! I changed my clock settings to PM, closed and reopened gadget just to be sure and it didn't switch to military time. No AM or PM display, but that's probably because it wasn't built in I'm guessing.

I can upload the Airlock HUD clock with standard time settings to Mediafire and link it if anyone's interested.

Thanks for the help!

YourNumbr1Fan
April 3rd, 2015, 06:14 PM
Okay, clock.js uses weird spacing in contrast to yours. I'm editing Airlock HUD digital clock btw.

It used weird spacing, so I went in and edited it manually, sticking to the spacing technique. I copy and pasted what you shared and it showed nothing on the clock. ( :o I broke it! yaaaaay!!!) Looks like it did the trick tho with the spacing! I changed my clock settings to PM, closed and reopened gadget just to be sure and it didn't switch to military time. No AM or PM display, but that's probably because it wasn't built in I'm guessing.

I can upload the Airlock HUD clock with standard time settings to Mediafire and link it if anyone's interested.

Thanks for the help!

No problem, man. To get the clock gadget to display am/pm, at least in the gadget you're talking about, there needs to be "AM" and "PM" images (like the numbers are images), and some code to tell the gadget to call those images, then vertical & horizontal (x, y) codes to place them where they need to be. All very do-able, of course. I'll work on it a little, later, and see if I can make some and compile the triggers. Due to the size of the numbers, I'd say that the AM and PM images need to be maybe a 3rd the size of those. Give me a bit (like a day) and I'll see what I can do for ya.

Also, the AM/PM display can be a part of the clock image (the background), with a colored light indicator to indicate AM or PM..... Personally, I think that would look much better (and be less work for me!, lol).

Terrapin2190
April 3rd, 2015, 11:13 PM
That would be awesome! I love how this forum is mildly active :) Win7 >>> Win8 imo.

Now to figure out why the computer status app won't recognize my wifi signal strength...

Airlock gadgets look nice paired w Sub Zero Sapphire theme. I'd try using Rainmeter, but my system doesn't like that very much. My computer's almost a decade old now, so go figure haha.

Terrapin2190
April 4th, 2015, 10:27 PM
No problem, man. To get the clock gadget to display am/pm, at least in the gadget you're talking about, there needs to be "AM" and "PM" images (like the numbers are images), and some code to tell the gadget to call those images, then vertical & horizontal (x, y) codes to place them where they need to be. All very do-able, of course. I'll work on it a little, later, and see if I can make some and compile the triggers. Due to the size of the numbers, I'd say that the AM and PM images need to be maybe a 3rd the size of those. Give me a bit (like a day) and I'll see what I can do for ya.

Also, the AM/PM display can be a part of the clock image (the background), with a colored light indicator to indicate AM or PM..... Personally, I think that would look much better (and be less work for me!, lol).

I'm thinking the AM/PM markers would need to go above the clock, since there isn't much room on either side. I wish I knew more about photoshop... I'd try to whip something up. Thinking along the lines of a smaller font matching the date indicator, but a 'digital shadow' like what you see with the clock, AM PM in the top right. Or a more rounded font/font matching digital, idk.

Now I'm working on adding radio stations to the Computer Status gadget. I started a thread about it in gadgets and sent a beacon to Pats. I have managed to add a few from Soma.fm since the website and streaming url's layouts were the same, but having trouble finding url info's when looking at player source codes for other stations around the net. And not quite sure what theXML string is.

Gotta shut these gadgets down when I play games though since my computer's reaching senior status haha.

YourNumbr1Fan
April 4th, 2015, 11:38 PM
I'm thinking the AM/PM markers would need to go above the clock, since there isn't much room on either side. I wish I knew more about photoshop... I'd try to whip something up. Thinking along the lines of a smaller font matching the date indicator, but a 'digital shadow' like what you see with the clock, AM PM in the top right. Or a more rounded font/font matching digital, idk.

Now I'm working on adding radio stations to the Computer Status gadget. I started a thread about it in gadgets and sent a beacon to Pats. I have managed to add a few from Soma.fm since the website and streaming url's layouts were the same, but having trouble finding url info's when looking at player source codes for other stations around the net. And not quite sure what theXML string is.

Gotta shut these gadgets down when I play games though since my computer's reaching senior status haha.

I'm a SOMA-FM guy too! SpacestationSoma & Underground 80s. I added those 2 in my own gadgets...

There are several things you can do with adding AM/PM markers. The sky's the limit. You could also, like I said earlier, have the indicators built in to the background....or like have the gadget use a different background for AM and then another for PM, each one with a different time-period lit up. I have some things I have to do today with my wife, but I'll hit you up with some fresh code and images later, ok. I love customizing and fiddling with gadgets and RainMeter-skins. :Peace:

2 dif backgrounds, like so:

69740 69741

All you need to do then, is direct the gadget to load one in AM and the other in PM.... which I think would require much less work/resources.

Terrapin2190
April 5th, 2015, 06:16 AM
I'm a SOMA-FM guy too! SpacestationSoma & Underground 80s. I added those 2 in my own gadgets...

There are several things you can do with adding AM/PM markers. The sky's the limit. You could also, like I said earlier, have the indicators built in to the background....or like have the gadget use a different background for AM and then another for PM, each one with a different time-period lit up. I have some things I have to do today with my wife, but I'll hit you up with some fresh code and images later, ok. I love customizing and fiddling with gadgets and RainMeter-skins. :Peace:

2 dif backgrounds, like so:

69740 69741

All you need to do then, is direct the gadget to load one in AM and the other in PM.... which I think would require much less work/resources.

CRAP! I forgot to back up my .js files before restoring my system image. I knew I was forgetting something! Ah well, it's not a ridiculous amount of work at least. I've been hooked on Groove Salad for the last 4 days btw haha. I love the tunes coming out of that station! Looks like the number graphics for the Airlock Blue gadgets are small/cropped images, so I'd imagine some image centering would be in order if I were to create am/pm markers. I don't even know where to begin when it comes to imaging. Or centering lol