INTERACT FORUM

Windows => Plug-in Development => Topic started by: EasyEd on February 24, 2009, 01:34:21 pm

Title: Date field
Post by: EasyEd on February 24, 2009, 01:34:21 pm
I am trying to work with the Date field, ie the recording date for a partular song.

If I use the Get("date",true) function it returns the correct date, say "1/1/1999"

If I then use Set("date,"1/1/1999"), MC shows a blank for the date.  If I then use the Get("date",true) it also returns blank. So I assume the date is stored in some other format, not a string.

If I use Get("date",false) it returns 36161.0000011574084056.  If I then use Set("date",n) where n=36161.0000011574084056, MC shows the correct date "1/1/1999"

So my question is can someone give me the calculation that MC uses to determine that number from the "1/1/1999" so I can input other dates?

Thanks

Ed
Title: Re: Date field
Post by: leezer3 on February 25, 2009, 10:35:20 am
Hiya,
MC internally stores the date in Unix format :) http://en.wikipedia.org/wiki/Unix_time
There are a couple of datetime scripts in the scripting thread ( http://yabb.jriver.com/interact/index.php?topic=33020.0 ), which have the calculation you're after in C#

Cheers

-Leezer-
Title: Re: Date field
Post by: Alex B on February 25, 2009, 10:56:44 am
MC internally stores the date in Unix format :) http://en.wikipedia.org/wiki/Unix_time
There are a couple of datetime scripts in the scripting thread ( http://yabb.jriver.com/interact/index.php?topic=33020.0 ), which have the calculation you're after in C#

The "Unix time" counts seconds since January 1, 1970. The date/time related library fields that store the current date/time value use the Unix system.

The Date field is different. The Date field is a day counter. The number 1 represents December 31, 1899. This system is used at least in Excel and some other MS programs.

More info:
http://yabb.jriver.com/interact/index.php?topic=43983.msg301174#msg301174
Title: Re: Date field
Post by: EasyEd on February 27, 2009, 12:23:52 pm
Thanks.

Apparently MC counts the days from 12/31/1899.  I found some visual basic date functions that will give me the number of days between 2 specific days.  So 12/31/1998 is 36160, 1/2/1999 is 36162.  I am still puzzled by 1/1/1999.  If I put in 36161 MC shows just 1999.  To get MC to show 1/1/1999 I have to use 36161.0000011574084056. 
By the way, I am using MC13.

Thanks again

Ed
Title: Re: Date field
Post by: leezer3 on February 28, 2009, 07:33:04 am
Thanks.

Apparently MC counts the days from 12/31/1899.  I found some visual basic date functions that will give me the number of days between 2 specific days.  So 12/31/1998 is 36160, 1/2/1999 is 36162.  I am still puzzled by 1/1/1999.  If I put in 36161 MC shows just 1999.  To get MC to show 1/1/1999 I have to use 36161.0000011574084056. 
By the way, I am using MC13.

Thanks again

Ed

I'll admit Alex B knows far more about this than me, however :)
If you read the linked thread, MC interprets some values for the date field differently, so that it can recognise for example plain 2003 (37622), as opposed to 01/01/2003. As far as I can tell, numbers after the decimal place are used to represent hours/ mins/ secs.
I can't get the sums to work out at the minute, but I'm guessing that 0.0000011574084056 probably equates to about a second or so- This would mean that MC recognises that you want 1/1/1999, as opposed to simply 1999 as a blanket year.


My head now hurts ;)

-Leezer-
Title: Re: Date field
Post by: Matt on March 06, 2009, 04:53:36 pm
Time is the decimal part of the number.  It's just the fraction of the day.

To differentiate between 2003 and 01/01/2003 and 01/01/2003 12:00 we add fractions of a second.

Here are our defines:

Code: [Select]
#define TIME_ONE_SECOND (1.0 / double(SECONDS_IN_DAY)) // one second
#define SPECIAL_TIME_SHOW_DAY (TIME_ONE_SECOND / 10.0) // one-tenth of a second
#define SPECIAL_TIME_SHOW_DAY_AND_TIME (SPECIAL_TIME_SHOW_DAY * 2.0) // two-tenths of a second