Hi,
How can I convert the time string to 12h format ?
Like this (without leading zeros):
"00:43" - "12:43 am"
"02:17" - "2:17 am"
"17:23" - "5:23 pm"
Thanks
It is currently April 19th, 2024, 7:23 pm
Convert time string to 12h format
-
- Posts: 865
- Joined: January 4th, 2018, 9:52 pm
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Convert time string to 12h format
Can you show me the measure that is getting the time to begin with? That matters... It's really, really hard to plot a course to a destination if you don't know where you are starting from!
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
[MeasureTime24]
Measure=String
String=17:51
[MeasureTime12]
Measure=Time
DynamicVariables=1
TimeStamp=[MeasureTime24]
TimeStampFormat=%H:%S
Format=%#I:%S %p
[MeterTime]
Meter=String
MeasureName=MeasureTime12
FontSize=25
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
StringCase=Lower
AntiAlias=1
https://docs.rainmeter.net/manual/measures/time/#TimeStamp
https://docs.rainmeter.net/manual/measures/time/#TimeStampFormat
https://docs.rainmeter.net/manual/measures/time/#FormatCodes
You do not have the required permissions to view the files attached to this post.
-
- Posts: 865
- Joined: January 4th, 2018, 9:52 pm
Re: Convert time string to 12h format
Thank you very much !jsmorley wrote: ↑November 22nd, 2019, 1:37 pm Can you show me the measure that is getting the time to begin with? That matters...
Code: Select all
[Rainmeter] Update=1000 DynamicWindowSize=1 AccurateText=1 [Variables] [MeasureTime24] Measure=String String=17:51 [MeasureTime12] Measure=Time DynamicVariables=1 TimeStamp=[MeasureTime24] TimeStampFormat=%H:%S Format=%#I:%S %p [MeterTime] Meter=String MeasureName=MeasureTime12 FontSize=25 FontWeight=400 FontColor=255,255,255,255 SolidColor=47,47,47,255 Padding=5,5,5,5 StringCase=Lower AntiAlias=1
1.png
https://docs.rainmeter.net/manual/measures/time/#TimeStamp
https://docs.rainmeter.net/manual/measures/time/#TimeStampFormat
https://docs.rainmeter.net/manual/measures/time/#FormatCodes
It works!
This is the measure:
Code: Select all
[MeasureSunrise]
Measure=WebParser
Url=[MeasureSun]
StringIndex=1
RegExpSubstitute=1
Substitute="^.*T(.*):.*$":"\1"
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Convert time string to 12h format
Yes, in this case my solution should be the right one. Glad to help.xenium wrote: ↑November 22nd, 2019, 2:04 pm Thank you very much !
It works!
This is the measure:Code: Select all
[MeasureSunrise] Measure=WebParser Url=[MeasureSun] StringIndex=1 RegExpSubstitute=1 Substitute="^.*T(.*):.*$":"\1"
-
- Rainmeter Sage
- Posts: 2604
- Joined: March 23rd, 2015, 5:26 pm