It is currently March 29th, 2024, 1:46 pm

config the clock to have the right time

Get help with installing and using Rainmeter.
CLLC
Posts: 7
Joined: April 16th, 2015, 10:00 am

config the clock to have the right time

Post by CLLC »

Hi everyone

I would like to config the clock to have the right time (from internet?).

Because my windows time is false and no-constant (server).

Any one have an idea?

I think maybe with the plugin "WebParser"
But i dont know where to download it, and what information i ve to write in clock.ini.


Im new here, and thank for this forum.
Im french, sorry for my bad english.
Thank you for your help!!
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: config the clock to have the right time

Post by balala »

To use the WebParser plugin you have to find a page which shows the time. I think you can't use the WebParser to get the time from a "time server" (like time.windows.com).
Do you have a such page?
CLLC
Posts: 7
Joined: April 16th, 2015, 10:00 am

Re: config the clock to have the right time

Post by CLLC »

Hi balala

Yes i know a page like " http://www.heure.com/ "
Its okay, or i have to found something like a RSS stream?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: config the clock to have the right time

Post by jsmorley »

That page won't work, as it is not returning the time as HTML that WebParser can see. it is some javascript that must be executed in a browser.

I think you can use http://www.timeanddate.com/worldclock/usa/washington-dc, finding and replacing your city in the URL.

My issue with this is that it won't be much of a "clock" really will it? You certainly can't hit a remote site once a second, so you will only be able to show this to the minute. In addition, while you can hit the site once a minute if you want, you can't hit once every minute "on the minute", so it won't change at the precise time.

If the goal is to know what the current time is sorta more or less, then I guess this is fine. It can't be used as a clock with any precision or accuracy. The time displayed won't be "now", but "when I last checked it".

What you might do is hit that site once an hour, getting the time down to the second. Then convert that to a Windows timestamp, which you use in a Time measure. Then have a counter that increments that value in the Time measure by 1 every skin update, with the Update set to 1000 (once a second, more or less).

Then you can have a "clock" that will display a reasonably accurate time, which you "sync / correct" once an hour. It might lose or gain a second or two in the course of an hour, as Update=1000 is not precisely "one second", but it will stay quite close.

I can go a bit deeper into the Time code required to get what I described above, but I'm hesitant to do so until I understand what the problem is that you have, and what you are really trying to accomplish. I'm not sure I see how any PC can even function without the date and time working.

If it were me, I'd find a solution to having the correct time set on the computer itself. I'm not sure I understand how you can have a PC that doesn't keep track of the current date and time. That is going to just wreak havoc with so many things. File timestamps, Windows Update, scheduled events, the list is endless.
CLLC
Posts: 7
Joined: April 16th, 2015, 10:00 am

Re: config the clock to have the right time

Post by CLLC »

Hi jsmorley

Thank you to make clear the problem!

I cant change the clock of Windows 7.
I am at work and the time is coming from the server. (i can't change it, and its not constant, and i can't ask my boss to try to solve it in the server)
So i would like a little opaque box, with the right time, to put on the false clock (right down corner).


I was thinking about the same solution:
to refresh the time every half-hour for exemple, and then run a local clock.

But i dont know how to program it with Rainmeter. I only know html/VBA code, but not *.ini files code.

Yes i can found my town here:
http://www.timeanddate.com/worldclock/france/lyon

Thank you very much if you can find a easy way to make it :)
And I know i' m not the only one!
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: config the clock to have the right time

Post by jsmorley »

Ok, give me a few minutes to work something up...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: config the clock to have the right time

Post by jsmorley »

Ok, here is what I worked up:
FakeClock_1.0.rmskin

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!ZPos "2"]

[MeasureTick]
Measure=Calc

[MeasureRemote]
Measure=Plugin
Plugin=WebParser
URL=http://www.timeanddate.com/worldclock/france/lyon
RegExp=(?siU)<div class=cityClock.*class=h1>(.*)</span>.*<span id=ctdat>(.*)</span>
UpdateRate=1800
FinishAction=[!SetOption MeasureTick Formula "0"][!UpdateMeasure MeasureTick][!SetOption MeasureTick Formula "MeasureTick + 1"][!UpdateMeasure MeasureTick][!EnableMeasureGroup Times]
DynamicVariables=1

[MeasureDate]
Measure=Plugin
Plugin=WebParser
URL=[MeasureRemote]
StringIndex=2

[MeasureTime]
Measure=Plugin
Plugin=WebParser
URL=[MeasureRemote]
StringIndex=1

[Measure24Hour]
Measure=String
String=[MeasureTime]
RegExpSubstitute=1
Substitute="^0":"","^12:(.*)PM":"12:\1","^1:(.*)PM":"13:\1","^2:(.*)PM":"14:\1","^3:(.*)PM":"15:\1","^4:(.*)PM":"16:\1","^5:(.*)PM":"17:\1","^6:(.*)PM":"18:\1","^7:(.*)PM":"19:\1","^8:(.*)PM":"20:\1","^9:(.*)PM":"21:\1","^10:(.*)PM":"22:\1","^11:(.*)PM":"23:\1","^12:(.*)AM":"0:\1","AM":"","(^\d:\d\d)":"0\1"
DynamicVariables=1

[MeasureTimeStatic]
Measure=Time
Group=Times
TimeStamp=[MeasureDate] [Measure24Hour]
TimeStampFormat=%A, %B %#d, %Y %H:%M:%S
TimeStampLocale=en-US
Disabled=1
DynamicVariables=1

[MeasureTimeCurrent]
Measure=Time
Group=Times
TimeStamp=([MeasureTimeStatic:TimeStamp] + [MeasureTick])
Format=%H:%M:%S
Disabled=1
DynamicVariables=1

[MeterTime]
Meter=String
MeasureName=MeasureTimeCurrent
FontSize=9
FontColor=255,255,255,255
SolidColor=55,69,84,255
Padding=5,5,5,5
AntiAlias=1
ToolTipText=[MeasureDate]
LeftMouseUpAction=["http://www.timeanddate.com/worldclock/france/lyon"]
DynamicVariables=1
Looks like this:
1.gif
And when I put it over the time widget on the Windows Taskbar:
1.png

So some explanation

The overall concept is much as I described earlier. Every half-hour (1800 seconds) We go out to that clock website, and get the date and time using WebParser in [MeasureRemote].

We then get the individual values for the date and the time with the WebParser child measures [MeasureDate] and [MeasureTime].

We are going use the new ability in Rainmeter 3.2 to pass a formatted date/time string to a Time measure and have it resolve this to a real "time" it can work with. This is described at TimeStamp option with more details and examples at Forum Post.

However, the new TimeStamp options are not good at dealing with 12-hour time indicated by the %p AM/PM codes. So what we have to do is convert the 12-hour time from the site to 24-hour time, which we do using a Substitute option on a String measure [Measure24Hour].

So now we have a Time measure that properly deals with the date and time returned from the web site. That is [MeasureTimeStatic]. That is the measure using the new TimeStamp options.

Now we need to "increase" that measure by 1 on each skin update, so it stays "current", and isn't just the static time from the parse of the site.

So we use a Calc measure [MeasureTick], which is controlled by the "FinishAction" on the WebParser measure. Once WebParser is done getting the date and time from the site, it resets and starts [MeasureTick] "ticking"...

We then dynamically add the value of [MeasureTick] to the value of [MeasureTimeStatic], and there we are... The current hours, minutes, seconds.

I then just made the opaque background of the meter the same as the color of my Windows Taskbar, and have the skin set to "stay topmost" with the !ZPos option when the skin is loaded or refreshed. That way it won't fight with the Windows Time widget on the Taskbar about who should be "on top". Windows wants to control that, so we have to force our skin back to the top on each update.

Note that I make no claim that this will be precise to the second at all times. It can take a handful of seconds to connect to and parse the remote site, which can throw it off a hair, and Update=1000 is not guaranteed to be exactly once a second in Rainmeter. However, this should be quite close and should stay quite close all the time. What I found is that it seemed to be pretty consistently 1 second "ahead of" the time displayed on the site, so I subtracted 1 second from the result like this:

TimeStamp=([MeasureTimeStatic:TimeStamp] + [MeasureTick] -1)

On my PC, that made it pretty darn close to exact. You might need a different number, like 3 or 7 or something, depending on how fast your internet connection is. Still, at the end of the day this isn't an atomic clock level of accuracy. It will just be pretty close to right.


Click to animate:
1.gif
Let me know if you have questions about this. It's not trivial to wrap your head around if you are new to Rainmeter, but should work pretty well as is.
You do not have the required permissions to view the files attached to this post.
CLLC
Posts: 7
Joined: April 16th, 2015, 10:00 am

Re: config the clock to have the right time

Post by CLLC »

Hi

Thank you very much.

I think i don't have the plugin WebParser, so it doesn't download the times informations from the website.
The clock start from "00:00:00' until its "00:30:00" and start again at "00:00:00".

After this little problem, it look perfect!

Thank you very much
CLLC
Posts: 7
Joined: April 16th, 2015, 10:00 am

Re: config the clock to have the right time

Post by CLLC »

I read that webparser is in rainmeter (i dont need to add it).
Do you know why i dont have the information from the website?

thanks!
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: config the clock to have the right time

Post by jsmorley »

CLLC wrote:I read that webparser is in rainmeter (i dont need to add it).
Do you know why i dont have the information from the website?

thanks!
No, you need to look at the log first, to see if there is an error. My guess, and it is only a guess, is that that site tailors the output when it detects the country or region the user's IP is in, so the RegExp needed to parse the information might be slightly different.

I would load the site in RainRegExp and test the RegExp and see if it needs tweaking when run from your location.

http://docs.rainmeter.net/tips/webparser-debugging-regexp