It is currently September 19th, 2020, 9:02 am

Date with no YMD

General topics related to Rainmeter.
mak_kawa
Posts: 863
Joined: December 30th, 2015, 9:47 am

Date with no YMD

Post by mak_kawa »

Maybe I am missing something...hope someone gives me an clarification.

When I give time data without year, month and day as TimeStamp to Time measure, ex."12:00", I receive date as 1900/01/01. Example code as follows;

Code: Select all

[Variables]
Date=12:00

[DateConv]
Measure=Time
TimeStamp=#Date#
TimeStampFormat=%H:%M
Format=%Y-%m-%d(%a) %H:%M
Result is 1900-01-01 (Mon) 12:00. I think that the Rainmeter assumes the Year-Month-Day as 1900-01-01 in the case of no YMD in the TimeStamp. Is it right?
If so, why 1900-01-01 instead of 1601-01-01 which is a start date of Windows time??

Ps. In the explanation of the format of TimeStamp in Rainmeter Documents, 3rd example is "2105" instead of "2015". Is it some joke or typo? :-)
User avatar
Brian
Developer
Posts: 2061
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Date with no YMD

Post by Brian »

This is a limitation of some of the underlying structures the C++ standard libraries uses to convert time formats to other formats.

This limitation should only happen when using TimeStampFormat option. We will look at documenting it.

[Detail]
When "reading" date/time information from a string, the time libraries from the C++ standard decided to use a "standard" time structure that does not accept years before 1900.
https://en.cppreference.com/w/c/chrono/tm

We even account for it here: https://github.com/rainmeter/rainmeter/blob/master/Library/MeasureTime.cpp#L447

I won't comment on why different operating systems and programming languages use such a wide variety of underlying date/time structures and functions...but I will say that Rainmeter relies heavily on the Windows api (or winapi), and we tend to use the native date/time structures that Windows uses/requires. The winapi makes conversion fairly easy - even when we have to do some of the work to convert correctly between different structures. The winapi mainly uses 3 different types of date/time structures for various reasons. The tm stucture (referenced above), SYSTEMTIME and FILETIME are the most common.
[/Detail]

-Brian
User avatar
Brian
Developer
Posts: 2061
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Date with no YMD

Post by Brian »

mak_kawa wrote: April 28th, 2020, 12:45 am Ps. In the explanation of the format of TimeStamp in Rainmeter Documents, 3rd example is "2105" instead of "2015". Is it some joke or typo? :-)
It's not technically incorrect, but for consistency with the other dates, it has been fixed. It was probably just a typo.

=Brian
mak_kawa
Posts: 863
Joined: December 30th, 2015, 9:47 am

Re: Date with no YMD

Post by mak_kawa »

Hi Brian

Thank you for detailed explanation. I acknowledged that it depends on C++ standard library.
In fact I have no problem/difficulty with it, so it's alright as is. Adding description to the documents seems to be even better.

Really appreciate for spending your time responding such question just out of my curiosity. :-)
User avatar
jsmorley
Developer
Posts: 21365
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Date with no YMD

Post by jsmorley »

I find this entire question a bit puzzling.

Why would you expect "In 12:37 pm, Columbus sailed the ocean blue" to make any sense?

I'm trying to understand what context you would use a TimeStamp of "HH:MM" and a TimeStampFormat that includes the year in.
User avatar
Yincognito
Posts: 2554
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Date with no YMD

Post by Yincognito »

jsmorley wrote: April 28th, 2020, 2:00 pm I find this entire question a bit puzzling.

Why would you expect "In 12:37 pm, Columbus sailed the ocean blue" to make any sense?

I'm trying to understand what context you would use a TimeStamp of "HH:MM" and a TimeStampFormat that includes the year in.
It doesn't make any sense, indeed. He was probably just curious why instead of the "zero"/"default" 1601 date he gets the 1900 one, I think.
User avatar
Brian
Developer
Posts: 2061
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Date with no YMD

Post by Brian »

After talking it over with jsmorley, and doing a little more research, we have come to the conclusion that the year 1900 is more of a "default" value in this case. It is perfectly acceptable to use TimeStampFormat with a 4 digit year format code %Y before the year 1990.

Personally, I think this default value is to accommodate the 2 digit %y year format code. In most use cases, a date with a 2 digit year, say 12/25/90, shouldn't parse to 1690, but to 1990.

These date "assumptions" should get interesting in about 50 years.

-Brian
User avatar
Yincognito
Posts: 2554
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Date with no YMD

Post by Yincognito »

Brian wrote: April 28th, 2020, 6:50 pmAfter talking it over with jsmorley, and doing a little more research, we have come to the conclusion that the year 1900 is more of a "default" value in this case. [...] Personally, I think this default value is to accommodate the 2 digit %y year format code. In most use cases, a date with a 2 digit year, say 12/25/90, shouldn't parse to 1690, but to 1990.
Yeah, this makes sense, actually - and it explains the behavior.
Brian wrote: April 28th, 2020, 6:50 pmThese date "assumptions" should get interesting in about 50 years.

-Brian
Now that's an excellent point. It'll be like the AD era or the Hijri era, people will eventually say ... "Look, it all started in the nineties". I wouldn't mind that personally, as those times were one of the happiest (and creative) everywhere on the planet.
mak_kawa
Posts: 863
Joined: December 30th, 2015, 9:47 am

Re: Date with no YMD

Post by mak_kawa »

Hi jsmorley

Sorry for bothering...and probably for my poor/broken English expression,

I have accidentally handled a timestamp without YMD to time measure, and received a start date of the 20th century. :-) So I was curious why not 1601/01/01 which is a start date of the Windows time? It's all (as Yincognito said). I have no intention to convert timestamp without YMD to some relevant/rational date.

I apologize for that useless question merely out of my curiosity.
User avatar
jsmorley
Developer
Posts: 21365
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Date with no YMD

Post by jsmorley »

mak_kawa wrote: April 28th, 2020, 9:23 pm Hi jsmorley

Sorry for bothering...and probably for my poor/broken English expression,

I have accidentally handled a timestamp without YMD to time measure, and received a start date of the 20th century. :-) So I was curious why not 1601/01/01 which is a start date of the Windows time? It's all (as Yincognito said). I have no intention to convert timestamp without YMD to some relevant/rational date.

I apologize for that useless question merely out of my curiosity.
Nothing to apologize for.