It is currently April 23rd, 2024, 8:51 pm

TimeStampFormat or string issue

Get help with creating, editing & fixing problems with skins
djamman
Posts: 10
Joined: January 3rd, 2020, 12:17 pm

TimeStampFormat or string issue

Post by djamman »

I am unable to parse a timestamp from a web site. I assume this is something really basic, sorry.

I rget the timestamp with no delineation characters and get a TimeStampFormat error parsing it. I get it as:
yyyymmddhhmmss where yyyy is the year, etc. So I tried TimeStampFormat=%Y%m%d%H%M%S and got an error. I simplified it to:

I want to interpret 123456 as 12 hours 34 minutes and 56 seconds

The following code gives me "Invalid TimeStampFormat: %H%M%S"
[MeasureDoDo]
Measure=Time
TimeStamp=123456
TimeStampFormat=%H%M%S
Format=%H:%M:%S

Thanks,
Doug
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: TimeStampFormat or string issue

Post by jsmorley »

djamman wrote: January 3rd, 2020, 12:41 pm I am unable to parse a timestamp from a web site. I assume this is something really basic, sorry.

I rget the timestamp with no delineation characters and get a TimeStampFormat error parsing it. I get it as:
yyyymmddhhmmss where yyyy is the year, etc. So I tried TimeStampFormat=%Y%m%d%H%M%S and got an error. I simplified it to:

I want to interpret 123456 as 12 hours 34 minutes and 56 seconds

The following code gives me "Invalid TimeStampFormat: %H%M%S"
[MeasureDoDo]
Measure=Time
TimeStamp=123456
TimeStampFormat=%H%M%S
Format=%H:%M:%S

Thanks,
Doug
Can you post an example of the entire date time format string you are getting from the website? 123456 is not really a "timestamp", and I'm not really following what you are trying to accomplish.

A "timestamp" is some number of seconds from either a Unix or Windows "epoch" date, and isn't a formatted string like yyyymmddhhmmss.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: TimeStampFormat or string issue

Post by mak_kawa »

Hi djamman

Because, non-formatted numeric timestamp means seconds value from 1601/01/01 00:00:00". For example, following measure returns the date of "1601/01/02 10:17:36" with no error. See the explanation in Rainmeter document.

Code: Select all

[MeasureDoDo]
Measure=Time
TimeStamp=123456
Format=%Y/%m/%d %H:%M:%S
So, as jsmorley said, you have to use formatted timestamp value/string.
Last edited by mak_kawa on January 3rd, 2020, 2:34 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: TimeStampFormat or string issue

Post by jsmorley »

20200103090530 is not a "timestamp", and in and of itself cannot be treated as a timestamp. It's just a string, that concatenates together values for year, month, day, hour, minute, second. That will need to be broken up into the various components, so they can be treated distinctly and unambiguously as the bits and pieces of a Time measure code.

There has to be a way to determine where the year stops and the month starts and so on. It can't be based on "length" in a TimeStampFormat option, it has to be based on distinct and static "delimiters".

So just use Substitute to force some delimiters into the correct spots in the string...

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[MeasureString]
Measure=String
String=20200103090530
RegExpSubstitute=1
Substitute="^([\d]{4})([\d]{2})([\d]{2})([\d]{2})([\d]{2})([\d]{2})$":"\1:\2:\3:\4:\5:\6"

[MeasureTime]
Measure=Time
TimeStamp=[MeasureString]
TimeStampFormat=%Y:%m:%d:%H:%M:%S
Format=%H:%M:%S
DynamicVariables=1

; Once you have the formatted string into a valid Time measure, this creates a "timestamp" you can use as you like.

[MeasureFullDateTime]
Measure=Time
TimeStamp=[MeasureTime:TimeStamp]
Format=%A, %B %#d, %Y %#I:%M %p
DynamicVariables=1

[MeterTime]
Meter=String
MeasureName=MeasureTime
MeasureName2=MeasureFullDateTime
FontSize=15
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=%2#CRLF##CRLF#%1

2.png


1.png
You do not have the required permissions to view the files attached to this post.
djamman
Posts: 10
Joined: January 3rd, 2020, 12:17 pm

Re: TimeStampFormat or string issue

Post by djamman »

Thanks jsmorley. That is what I needed.

I thought %Y had an implied lenght of 4, so delimieters wouldn't be needed.

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

Re: TimeStampFormat or string issue

Post by jsmorley »

djamman wrote: January 3rd, 2020, 3:04 pm Thanks jsmorley. That is what I needed.

I thought %Y had an implied lenght of 4, so delimieters wouldn't be needed.

Doug
Glad to help. No, there are no implied lengths when a Time measure is parsing a formatted string. You have to be distinct about where things start and end.