It is currently January 26th, 2021, 8:56 pm

Help for converting clock skin format to 12-hour format

Help with creating, editing & fixing problems with skins
Tejas
Posts: 20
Joined: January 7th, 2021, 9:32 am

Help for converting clock skin format to 12-hour format

Post by Tejas »

Hye everyone, I downloaded this new skin and I wonder if anyone can please convert the time to 12 hour format in this code. :D

Here's the code :

Code: Select all

[Rainmeter]
Author=addyf812
MouseOverAction=!Execute [!RainmeterShowMeter MeterClose][!RainmeterRedraw]
MouseLeaveAction=!Execute [!RainmeterHideMeter MeterClose][!RainmeterRedraw]
MiddleMouseDownAction=!RainmeterDeactivateConfig
BackgroundMode=1
Update=50

--------------------------------------------------------------------------
Activ Clock by afinday  -  http://addyf812.deviantart.com
--------------------------------------------------------------------------

;Metadata added by RainBrowser
;http://rainmeter.net/RainCMS/?q=Rainmeter101_AnatomyOfASkin

[Metadata]
Name=Activ Clock
Config=Activ Clock | Type 01 - Alarm OFF
Description=Displays the current date and time.
Instructions=Click on "05:00" to set your alarm. You can turn ON/OFF alarm by clicking on the icon.
Version=1.1.0
Tags=
License=Creative Commons BY-NC-SA 3.0
Variant=Activ Clock | Type 01 - Alarm OFF
Preview=#SKINSPATH#\Activ Clock\s_01.png

;End of added Metadata

[Variables]
@include=#SKINSPATH#\Activ Clock\UserVariables.inc



; ----------------------------------
; MEASURES
; ----------------------------------

[MeasureTime]
Measure=Time
AverageSize=20 

[MeasureChimeHour]
Measure=Time
Format=%M
IfEqualValue=0
IfEqualAction=[Play "#@#Sounds\HourChime.wav"]

[MeasureSec]
Measure=Time
Format=%S

[MeasureHour]
Measure=Time
Format=%H

[MeasureMinute]
Measure=Time
Format=%M

[MeasureDate]
Measure=Time
Format=%#d

[MeasureAMPM]
Measure=Time
Format=%p
Substitute="AM":"00","PM":"01"

[MeasureGetAMPM]
Measure=Calc
Formula=[MeasureAMPM]
DynamicVariables=1

[MeasureMonth]
Measure=Time
Format=%B
Substitute="January":"Jan","February":"Feb","March":"Mar","April":"Apr","May":"May","June":"June","July":"July","August":"Aug","September":"Sep","October":"Oct","November":"Nov","December":"Dec"

[MeasureDay]
Measure=Time
Format=%A
Substitute="Monday":"Mon","Tuesday":"Tue","Wednesday":"Wed","Thursday":"Thu","Friday":"Fri","Saturday":"Sat","Sunday":"Sun"

[MeasureYear]
Measure=Time
Format=%Y

; ----------------------------------
; METERS
; ----------------------------------

[am-pm]
Meter=Bitmap
MeasureName=MeasureGetAMPM
Bitmapimage=am_pm.png
X=167
Y=19
Bitmapframes=2
Bitmapextend=1
Bitmapdigits=1

[Hour]
Meter=Bitmap
MeasureName=MeasureHour
Bitmapimage=clock_digit_0_9.png
Bitmapframes=10
X=41
Y=19
Bitmapextend=1
Bitmapdigits=2

[Minute]
Meter=Bitmap
MeasureName=MeasureMinute
Bitmapimage=clock_digit_0_9.png
Bitmapframes=10
X=65r
Y=r
Bitmapextend=1
Bitmapdigits=2

[MeterSeconds]
Meter=String
MeasureName=MeasureSec
X=167
Y=32
FontFace=SomaRoman
FontColor=255,255,255
FontSize=10
StringStyle=Normal
AntiAlias=1
Text=%1

[Second2]
Meter=Bitmap
MeasureName=MeasureSec
Bitmapimage=colon_night.png
Bitmapframes=10
X=96
Y=19
Bitmapextend=1
Bitmapdigits=1

[MeterDate]
Meter=String
MeasureName=MeasureDate
X=93
Y=69
FontFace=SomaRoman
FontColor=255,255,255
FontSize=9
StringStyle=Bold
AntiAlias=1
Text=%1,
ToolTipText="Adjust Date/Time"
LeftMouseUpAction=!Execute [control.exe timedate.cpl]
MouseActionCursor=1

[MeterDay]
Meter=STRING
MeasureName=MeasureDay
X=112
Y=96
FontFace=SomaRoman
FontColor=255,255,255
FontSize=9
StringStyle=Bold
AntiAlias=1
Text="%1"

[MeterMonth]
Meter=String
MeasureName=MeasureMonth
X=67
Y=69
FontFace=SomaRoman
FontColor=255,255,255
FontSize=9
StringStyle=Bold
AntiAlias=1
Text=%1
ToolTipText="Adjust Date/Time"
LeftMouseUpAction=!Execute [control.exe timedate.cpl]
MouseActionCursor=1

[MeterYear]
Meter=String
MeasureName=MeasureYear
X=117
Y=69
FontFace=SomaRoman
FontColor=255,255,255
FontSize=9
StringStyle=Bold
AntiAlias=1
Text=%1
ToolTipText="Adjust Date/Time"
LeftMouseUpAction=!Execute [control.exe timedate.cpl]
MouseActionCursor=1

[AlarmButton]
Meter=IMAGE
ImageName=alarm_disabled.png
X=58
Y=96
W=11
LeftMouseUpAction=!Execute [PLAYSTOP][!RainmeterActivateConfig "Activ Clock\01" "Activ Clock - D2.ini"][!RainmeterRefresh]
ToolTipText="Turn ON alarm"
MouseActionCursor=1

[AlarmText]
Meter=String
MeterStyle=Style
Text=#ALARMHOUR#:#ALARMMINUTE#,
X=74
Y=96
StringAlign=LEFT
StringStyle=Bold
FontFace=SomaRoman
FontColor=255,255,255
AntiAlias=1
FontSize=9
ToolTipText="Set your alarm"
LeftMouseUpAction=!Execute ["#SKINSPATH#\Activ Clock\Config\config.exe" #CURRENTCONFIG#][!RainmeterRefresh]
MouseActionCursor=1


--------------------------------------

[MeterClose]
Meter=BUTTON
ButtonImage=#SKINSPATH#\Activ Clock\close.png
X=196
Y=3
ButtonCommand=!RainmeterDeactivateConfig
Hidden=0
User avatar
SilverAzide
Rainmeter Sage
Posts: 1098
Joined: March 23rd, 2015, 5:26 pm

Re: Help for converting clock skin format to 12-hour format

Post by SilverAzide »

Tejas wrote: January 8th, 2021, 12:35 pm Hye everyone, I downloaded this new skin and I wonder if anyone can please convert the time to 12 hour format in this code. :D
I did not try that skin, but have you tried changing the [MeasureHour] measure to use 12-hour time? The format code is either %I or %#I, depending on whether you want leading zeroes or not.

Code: Select all

[MeasureHour]
Measure=Time
Format=%#I
You can find the documentation here: https://docs.rainmeter.net/manual/measures/time/#FormatCodes.
Gadgets Wiki GitHub More Gadgets...
Tejas
Posts: 20
Joined: January 7th, 2021, 9:32 am

Re: Help for converting clock skin format to 12-hour format

Post by Tejas »

Thanks bro shall try it next time I open my laptop.
User avatar
jsmorley
Developer
Posts: 21470
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help for converting clock skin format to 12-hour format

Post by jsmorley »

Seems to me that the version of this skin posted on deviantART is already in 12hour format. Maybe just download and install it again.

https://www.deviantart.com/addyf812/art/Activ-Clock-275855601
User avatar
balala
Rainmeter Sage
Posts: 12112
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help for converting clock skin format to 12-hour format

Post by balala »

jsmorley wrote: January 8th, 2021, 1:23 pm Seems to me that the version of this skin posted on deviantART is already in 12hour format. Maybe just download and install it again.

https://www.deviantart.com/addyf812/art/Activ-Clock-275855601
No, it's not. even if it shows up AM / PM, it is in a 24-hour format. Unfortunate choice, but that's it. And even in the code posted by OP in the first post it is so, with hours in 24-hour format.
SilverAzide wrote: January 8th, 2021, 1:16 pm I did not try that skin, but have you tried changing the [MeasureHour] measure to use 12-hour time? The format code is either %I or %#I, depending on whether you want leading zeroes or not.

Code: Select all

[MeasureHour]
Measure=Time
Format=%#I
This is good, but probably not enough, because there is one more Time measure which is using the hour: [MeasureExecuteMinute]. The %I format parameter should be replaced there as well, but this creates a new problem, namely that the alarm won't work well, because won't make the difference between AM and PM times.
Tejas, if you need the alarm as well, let me know and I'm gonna rewrite a few things to get it working again.

Addional note: both the !Execute bang and the !Rainmeter... bang prefix have been deprecated long time ago and should be removed, even if the code (for backward compatibility reasons) are still working with them.
Tejas
Posts: 20
Joined: January 7th, 2021, 9:32 am

Re: Help for converting clock skin format to 12-hour format

Post by Tejas »

Yes I want them. Please edit the code as you wish so that it works properly. Thanks again. 😁😁
User avatar
balala
Rainmeter Sage
Posts: 12112
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help for converting clock skin format to 12-hour format

Post by balala »

Tejas wrote: January 8th, 2021, 5:22 pm Yes I want them. Please edit the code as you wish so that it works properly.
Alright, here it is. First add an ALARMAMPM variable to the [Variables] section of the Activ Clock\UserVariables.inc file. This variable has to be either 1 if you want to set the alarm for PM, or 0 for AM. However note that the settings tool (the included config.exe) won't be able to set this variable as well, for now on you have to update it manually. Me personally prefer not to use a .exe for settings, if you need / want a newlly written skin would be much beter to make the settings.
Replace the code of the skin with the following one:

Code: Select all

[Rainmeter]
MouseOverAction=[!ShowMeter MeterClose][!Redraw]
MouseLeaveAction=[!HideMeter MeterClose][!Redraw]
MiddleMouseDownAction=[!DeactivateConfig]
BackgroundMode=1
Update=1000

;--------------------------------------------------------------------------
;Activ Clock by afinday  -  http://addyf812.deviantart.com
;--------------------------------------------------------------------------

;Metadata added by RainBrowser
;http://rainmeter.net/RainCMS/?q=Rainmeter101_AnatomyOfASkin

[Metadata]
Name=Activ Clock
Author=addyf812
Config=Activ Clock | Type 01 - Alarm ON
Description=Displays the current date and time.
Instructions=Click on "05:00" to set your alarm. You can turn ON/OFF alarm by clicking on the icon.
Version=1.1.0
License=Creative Commons BY-NC-SA 3.0
Variant=Activ Clock | Type 01 - Alarm ON
Preview=#SKINSPATH#\Activ Clock\s_01.png

;End of added Metadata

[Variables]
@include=#SKINSPATH#\Activ Clock\UserVariables.inc

[Background]
Meter=Image
ImageName=bg_night.png
W=210
H=123

; ----------------------------------
; MEASURES
; ----------------------------------

[MeasureTime]
Measure=Time
AverageSize=20 

[MeasureSec]
Measure=Time
Format=%S

[MeasureHour]
Measure=Time
Format=%I

[MeasureMinute]
Measure=Time
Format=%M

[MeasureDate]
Measure=Time
Format=%#d

[MeasureAMPM]
Measure=Time
Format=%p
Substitute="AM":"0","PM":"1"

[MeasureGetAMPM]
Measure=Calc
Formula=[MeasureAMPM]
DynamicVariables=1

[MeasureMonth]
Measure=Time
Format=%b

[MeasureDay]
Measure=Time
Format=%a

[MeasureYear]
Measure=Time
Format=%Y

[MeasureExecuteMinute] 
Measure=Time 
Format=%I%M

[MeasureAlarm]
Measure=Calc
Formula=( 10000 * [MeasureAMPM] + MeasureExecuteMinute )
IfCondition=(#CURRENTSECTION#=10000*#ALARMAMPM#+100*#ALARMHOUR#+#ALARMMINUTE#)
IfTrueAction=[PLAYLOOP #Alarmsound#]
DynamicVariables=1

; ----------------------------------
; METERS
; ----------------------------------

[am-pm]
Meter=Bitmap
MeasureName=MeasureGetAMPM
Bitmapimage=am_pm.png
X=167
Y=19
Bitmapframes=2
Bitmapextend=1
Bitmapdigits=1

[Hour]
Meter=Bitmap
MeasureName=MeasureHour
Bitmapimage=clock_digit_0_9.png
Bitmapframes=10
X=41
Y=19
Bitmapextend=1
Bitmapdigits=2

[Minute]
Meter=Bitmap
MeasureName=MeasureMinute
Bitmapimage=clock_digit_0_9.png
Bitmapframes=10
X=65r
Y=r
Bitmapextend=1
Bitmapdigits=2

[MeterSeconds]
Meter=String
MeasureName=MeasureSec
X=167
Y=32
FontFace=SomaRoman
FontColor=255,255,255
FontSize=10
StringStyle=Normal
AntiAlias=1
Text=%1

[Second2]
Meter=Bitmap
MeasureName=MeasureSec
Bitmapimage=colon_night.png
Bitmapframes=10
X=96
Y=19
Bitmapextend=1
Bitmapdigits=1

[MeterDate]
Meter=String
MeasureName=MeasureDate
X=93
Y=69
FontFace=SomaRoman
FontColor=255,255,255
FontSize=9
StringStyle=Bold
AntiAlias=1
Text=%1,
ToolTipText=Adjust Date/Time
LeftMouseUpAction=[control.exe timedate.cpl]
MouseActionCursor=1

[MeterDay]
Meter=STRING
MeasureName=MeasureDay
X=112
Y=96
FontFace=SomaRoman
FontColor=255,255,255
FontSize=9
StringStyle=Bold
AntiAlias=1
Text=%1

[MeterMonth]
Meter=String
MeasureName=MeasureMonth
X=67
Y=69
FontFace=SomaRoman
FontColor=255,255,255
FontSize=9
StringStyle=Bold
AntiAlias=1
Text=%1
ToolTipText="Adjust Date/Time"
LeftMouseUpAction=[control.exe timedate.cpl]
MouseActionCursor=1

[MeterYear]
Meter=String
MeasureName=MeasureYear
X=117
Y=69
FontFace=SomaRoman
FontColor=255,255,255
FontSize=9
StringStyle=Bold
AntiAlias=1
Text=%1
ToolTipText="Adjust Date/Time"
LeftMouseUpAction=[control.exe timedate.cpl]
MouseActionCursor=1

[AlarmButton]
Meter=IMAGE
ImageName=alarm_enabled.png
X=58
Y=96
W=11
LeftMouseUpAction=[PLAYSTOP][!ActivateConfig "Activ Clock\01" "Activ Clock - D1.ini"][!Refresh]
ToolTipText="Turn OFF alarm"
MouseActionCursor=1

[AlarmText]
Meter=String
MeterStyle=Style
Text=#ALARMHOUR#:#ALARMMINUTE#,
X=74
Y=96
StringAlign=LEFT
StringStyle=Bold
FontFace=SomaRoman
FontColor=255,255,255
AntiAlias=1
FontSize=9
ToolTipText="Set your alarm"
LeftMouseUpAction=["#SKINSPATH#\Activ Clock\Config\config.exe" #CURRENTCONFIG#][!Refresh]
MouseActionCursor=1

;--------------------------------------

[MeterClose]
Meter=BUTTON
ButtonImage=#SKINSPATH#\Activ Clock\close.png
X=196
Y=3
ButtonCommand=[!DeactivateConfig]
Hidden=0
Note a few things which I upaded, beside what have I wrote:
  • Slightly modified the Substitute option of the [MeasureAMPM] measure.
  • Removed the Substitute options of the [MeasureMonth] and [MeasureDay] measures and replaced their format option with Format=%b and Format=%a, accordingly. No need to get the full month and day names, then substitute them to get the short names. The used Formats assure you to get directly the short names.
  • Added the [MeasureAlarm] measure and moved the IfActions from the [MeasureExecuteMinute] measure here. Also replaced these options with IfCondition (as previously said, it's much more versatile).
  • Removed the quotes from a lot of options, where they were not needed.
  • Get completely rid of the !Execute bangs and the !Rainmeter... bang prefixes, which as said, have been long time ago deprecated.
  • Moved the Author option from [Rainmeter] to [Metadata]. Once it belonged to [Rainmeter], but in meantime it has been moved to [Metadata].
  • A few other, minor updates.
I made all the updates on the Activ Clock\01\Activ Clock - D2.ini skin. Even if didn't try out, I suppose the same way you can change any other skin of the package.
Please test the code and let me know if it's alright.