It is currently September 29th, 2023, 1:57 pm

Help with elapsed days

Get help with creating, editing & fixing problems with skins
User avatar
HLHM
Posts: 7
Joined: August 13th, 2023, 2:07 pm

Help with elapsed days

Post by HLHM »

Hello. I am stuck. I have managed to get elapsed minutes and hours
but i can't figure out how to get elapsed days.

Code: Select all

[mTimeNow]
Measure=Time

[mStartingTime]
Measure=Time
UpdateDivider=-1

[mHours]
Measure=Time
TimeStamp=([mTimeNow:]-[mStartingTime:])
DynamicVariables=1
Format=%#H

[mMinutes]
Measure=Time
TimeStamp=([mTimeNow:]-[mStartingTime:])
DynamicVariables=1
Format=%M

[mTimeInMinutesCalc]
Measure=Calc
Formula=(( [mHours] * 60 ) + [mMinutes] )
DynamicVariables=1

[mDaysCalc]
Measure=Calc
Formula=?????
DynamicVariables=1

[Meter1]
Meter=String
MeasureName=mHours
Text="%1 hours"

[Meter2]
Meter=String
MeasureName=mMinutes
Y=10R
text="%1 minutes"

[Meter3]
Meter=String
MeasureName=mDaysCalc
Y=10R
text="%1 days"


User avatar
Yincognito
Rainmeter Sage
Posts: 6059
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Help with elapsed days

Post by Yincognito »

HLHM wrote: September 8th, 2023, 6:29 pm but i can't figure out how to get elapsed days
If you figured out the time in minutes formula, this is no different: just divide the time difference by the number of seconds in a day, i.e. 86400 (aka 24*60*60).

P.S. You might take a look at the Uptime measure, it should already display most of what you need if you set its SecondsValue to the time difference.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 15680
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with elapsed days

Post by balala »

HLHM wrote: September 8th, 2023, 6:29 pm Hello. I am stuck. I have managed to get elapsed minutes and hours
but i can't figure out how to get elapsed days.
First a few thigs related to the posted code:
  • The [mHours] and [mMinutes] measures are returning numbers, so you don't have to use their values as section variables into the Formula option of the [mTimeInMinutesCalc] measure. You can use the formula in the following form: Formula=(( mHours * 60 ) + mMinutes ). This makes useless the DynamicVariables=1 option as well onto the measure. Remove it as well.
  • In the TimeStamp options of the [mHours] and [mMinutes] measures you're using the timestamps of the [mTimeNow] and [mStartingTime] Time measures, so you should use their TimeStamp section variables:

    Code: Select all

    [mHours]
    ...
    TimeStamp=([mTimeNow:TimeStamp]-[mStartingTime:TimeStamp])
    ...
    
    [mMinutes]
    ...
    TimeStamp=([mTimeNow:TimeStamp]-[mStartingTime:TimeStamp])
    ...
  • Try the following Formula on the [mDaysCalc] calc: Formula=( Floor ( mHours / 24 )) (but this is absolutely not needed, see below).
  • Finally and most important: as suggested by Yincognito, you could use the difference of timestamps of the [mTimeNow] and [mStartingTime] measure directly into the SecondsValue option of an Uptime measure. This measure, if properly written, can return the formatted time, without having you to calculate the number of minutes, hours and days (or even of seconds). If you are interested, try replacing the [mHours], [mMinutes], [mTimeInMinutesCalc] and [mDaysCalc] measures by the following one:

    Code: Select all

    [MeasureTime]
    Measure=Uptime
    Format=%4!i!d %3!i!:%2!02i!:%1!02i!
    SecondsValue=([mTimeNow:TimeStamp]-[mStartingTime:TimeStamp])
    DynamicVariables=1
  • With this measure, you don't need anymore all those String meters either. Replace them by the following one:

    Code: Select all

    [Meter]
    Meter=String
    MeasureName=MeasureTime
    Text=%1
Much simpler in my opinion. If you want another format of the returned time, you can alter it by altering the Format option of the above, newly added [MeasureTime] measure. If it's not clear what all those elements in the option are meaning, please let me know, for further assitance.

Taking all this into account, your code should look this way:

Code: Select all

[mTimeNow]
Measure=Time

[mStartingTime]
Measure=Time
UpdateDivider=-1

[MeasureTime]
Measure=Uptime
Format=%4!i!d %3!i!:%2!02i!:%1!02i!
SecondsValue=([mTimeNow:TimeStamp]-[mStartingTime:TimeStamp])
DynamicVariables=1

[Meter]
Meter=String
MeasureName=MeasureTime
Text=%1