Compute Release Date - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

SKArcade
Posts: 3
Joined: Mon Mar 18, 2013 3:27 am

Compute Release Date

Hi there,

I was wondering if anyone could help? I found this post - http://www.advancedinstaller.com/forums ... 44&start=0

This answers what I need to do, but unfortunately I do not understand the code. Can someone please give me some C# code to translate today's date into the value expected in the 'ReleaseDate' tag?

Thanks.
SKArcade
Posts: 3
Joined: Mon Mar 18, 2013 3:27 am

Re: Compute Release Date

Actually, I have managed to convert the code to C#, but my problem now is that this is for converting the ReleaseDate into year/month/day values, but I need help to go the other way.

Code: Select all

int releaseDate = 17010;

int YEAR_MASK = 0xFE00;
int YEAR_OFFSET = 9;

int MONTH_MASK = 0x01E0;
int MONTH_OFFSET = 5;

int DAY_MASK = 0x001F;

int testYear = ((releaseDate & YEAR_MASK) >> YEAR_OFFSET) + 1980;
int testMonth = ((releaseDate & MONTH_MASK) >> MONTH_OFFSET);
int testDay = (releaseDate & DAY_MASK);

DateTime result = new DateTime(testYear, testMonth, testDay);
SKArcade
Posts: 3
Joined: Mon Mar 18, 2013 3:27 am

Re: Compute Release Date

This seems to do the trick...

Code: Select all

int YEAR_OFFSET = 9;
int MONTH_OFFSET = 5;

int releaseDate = ((DateTime.Today.Year - 1980) << YEAR_OFFSET) +
                  (DateTime.Today.Month << MONTH_OFFSET) + 
                  DateTime.Today.Day;
agelinaking
Posts: 1
Joined: Wed Apr 03, 2013 7:12 am
Contact: Website

Re: Compute Release Date

SKArcade wrote:Actually, I have managed to convert the code to C#, but my problem now is that this is for converting the ReleaseDate into year/month/day values, but I need help to go the other way.

Code: Select all

int releaseDate = 17010;

int YEAR_MASK = 0xFE00;
int YEAR_OFFSET = 9;

int MONTH_MASK = 0x01E0;
int MONTH_OFFSET = 5;

int DAY_MASK = 0x001F;

int testYear = ((releaseDate & YEAR_MASK) >> YEAR_OFFSET) + 1980;
int testMonth = ((releaseDate & MONTH_MASK) >> MONTH_OFFSET);
int testDay = (releaseDate & DAY_MASK);

DateTime result = new DateTime(testYear, testMonth, testDay);
hmm...yeah dude you are right i am totally agree with you. :geek:

Return to “Common Problems”