INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Date field  (Read 4168 times)

EasyEd

  • Regular Member
  • Recent member
  • *
  • Posts: 41
Date field
« 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
Logged

leezer3

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1587
Re: Date field
« Reply #1 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-
Logged

Alex B

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 10121
  • The Cosmic Bird
Re: Date field
« Reply #2 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
Logged
The Cosmic Bird - a triple merger of galaxies: http://eso.org/public/news/eso0755

EasyEd

  • Regular Member
  • Recent member
  • *
  • Posts: 41
Re: Date field
« Reply #3 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
Logged

leezer3

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1587
Re: Date field
« Reply #4 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-
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42323
  • Shoes gone again!
Re: Date field
« Reply #5 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
Logged
Matt Ashland, JRiver Media Center
Pages: [1]   Go Up