It is currently April 24th, 2024, 3:31 am

Just Little Help (I need)

General topics related to Rainmeter.
kohamo
Posts: 2
Joined: March 29th, 2020, 7:01 pm

Just Little Help (I need)

Post by kohamo »

Hello,

Below is a code to display "Windows Taskbar Clock" and I'm trying to Add (addition) extra 10 mins in the time displayed by this code so that this will display the correct time.

Could anyone please help me to add extra 30 mins in the below code (I already tried my best but I couldn't)


Code: Select all

[Rainmeter]
Name = Windows Taskbar Clock
Author = lynxNZL
OnRefreshAction=[!ZPos "2"]

[Variables]
text_color = 255,255,255,255
bg_color = 0,0,0,1
font = Segoe UI SemiLight
fontsize = 9
w = 70 
h = 40

[MeasureOne]
Measure=Calc
Formula=5

[MeasureTwo]
Measure=Calc
Formula=MeasureOne < 6 ? 0 : 10

[MeasureClock]
Measure = Time
Format = %#I:%M  %p
DaylightSavingTime=0 
Timezone =+5:30


[MeasureDate]
Measure = Time
Format = %#d/%m/%Y

[FontStyle]
FontFace = #font#
FontSize = #fontsize#
FontColor = #text_color#
StringAlign = center
AntiAlias = 1


[Size]
Meter = Image
SolidColor = #bg_color#
w = #w#
h = #h#

[MeterClock]
Meter = STRING
MeasureName = MeasureClock
MeterStyle = FontStyle
X = (#w#/2)
Y = 2

[MeterDate]
Meter = STRING
MeasureName = MeasureDate
MeterStyle = FontStyle
X = r
Y = R
Last edited by balala on March 29th, 2020, 7:30 pm, edited 1 time in total.
Reason: Please use <code> tags whenever are you posting code snippets. It's the </> button.
User avatar
balala
Rainmeter Sage
Posts: 16164
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Just Little Help (I need)

Post by balala »

kohamo wrote: March 29th, 2020, 7:10 pm Below is a code to display "Windows Taskbar Clock" and I'm trying to Add (addition) extra 10 mins in the time displayed by this code so that this will display the correct time.

Could anyone please help me to add extra 30 mins in the below code (I already tried my best but I couldn't)
Related to your code note first that TimeZone within any Time measure is a decimal number. You can't set it to TimeZone=+5:30. It has to be TimeZone=5.5 instead, so modify this option.
This being said, here is what you have to do: first you need a new simple Time measure, with the same settings as the current Time measure. Add it to your code:

Code: Select all

[MeasureNow]
Measure=Time
DaylightSavingTime=0
Timezone=5.5
We'll add half of hour to the timestamp of this measure. Add the following two options to the [MeasureClock] measure:

Code: Select all

[MeasureClock]
...
TimeStamp=([MeasureNow:TimeStamp]+30*60)
DynamicVariables=1
where 30*60 is the amount of the seconds which has to be added to the timestamp.
With all this, your [MeasureClock] measure look this way:

Code: Select all

[MeasureClock]
Measure=Time
Format=%#I:%M  %p
DaylightSavingTime=0
TimeStamp=([MeasureNow:TimeStamp]+30*60)
Timezone=5.5
DynamicVariables=1
If you want to add not half of hour, but 10 minutes (you said both of this above), obviously you have to modify the 30*60 to 10*60 in the TimeStamp option.
Just one more detail I'd add here: probably a similar amount of time should be added to the [MeasureDate] measure as well, isn't it?
kohamo
Posts: 2
Joined: March 29th, 2020, 7:01 pm

Re: Just Little Help (I need)

Post by kohamo »

balala wrote: March 29th, 2020, 7:59 pm Related to your code note first that TimeZone within any Time measure is a decimal number...................................................

If you want to add not half of hour, but 10 minutes (you said both of this above), obviously you have to modify the 30*60 to 10*60 in the TimeStamp option.
Just one more detail I'd add here: probably a similar amount of time should be added to the [MeasureDate] measure as well, isn't it?
I'm so grateful to you :) for sharing the code to add 30mins to time and also mentioning about adding 10mins, you're awesome :)

As you mentioned about date:

>Just one more detail I'd add here: probably a similar amount of time should be added to the [MeasureDate] measure as well, isn't it?
I tried to do that but...
May I ask you:

1. Why "similar amount of time should be added to the [MeasureDate] measure as well"? When we already added extra 30 mins to time?

2. Secondly, if I want to add 1 extra day to existing date then what code should I need to add?

BTW you're genius :thumbup:
User avatar
balala
Rainmeter Sage
Posts: 16164
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Just Little Help (I need)

Post by balala »

kohamo wrote: March 29th, 2020, 10:50 pm 1. Why "similar amount of time should be added to the [MeasureDate] measure as well"? When we already added extra 30 mins to time?
Because the [MeasureDate] measure doesn't reuse the settings made on [MeasureClock]. If you wanna use them in "accordance", you have to add the same amount of time (as well as setting the same TimeZone) to both measures. For instance if you set the same TimeZone on both measures, but you don't add the half of hour to [MeasureDate], the clock will be at 12:30 AM when the date changes. Not sure about your intention, but it looks more logical by adding the same number of seconds to both measures.
kohamo wrote: March 29th, 2020, 10:50 pm 2. Secondly, if I want to add 1 extra day to existing date then what code should I need to add?
Add the following two options to the [MeasureDate] measure:

Code: Select all

[MeasureDate]
...
TimeStamp=([MeasureNow:TimeStamp]+86400)
DynamicVariables=1
where 86400 is the number of seconds of a day.