Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compilation date [closed]




On Nov 22, 2007, at 9:48 PM, Patrick Lacour wrote:

Or use this legacy "DOS date" ? I would search in zip specs... Date of ZIP building will be better than compilation date, since it would reflect not only bytecode modification, but also resources modifs.

This isn't originally mine but I've been using it for some time...

/**
* Converts the <tt>.zip</tt> time and date into a Date object.
* @param time the <tt>.zip</tt> time.
* @param date the <tt>.zip</tt> date.
* @return a Date object with the <tt>.zip</tt> time and date.
**/
static Date timeAndDate(int time, int date) {
time = shuffleShort(time);
date = shuffleShort(date);

int seconds = (time & 0x001F) << 1;
int minutes = (time & 0x07E0) >> 5;
int hours = (time & 0xF800) >> 11;
int day = date & 0x001F;
int month = (date & 0x01E0) >> 5;
int year = (date & 0xFE00) >> 9;

return new Date(year + 80, --month, day, hours, minutes, seconds);
}

/**
* Converts the time in a Date object to a <tt>.zip</tt> time.
* @param date the Date object.
* @return the <tt>.zip</tt> time.
**/
static int zipTime(Date date) {
int seconds = date.getSeconds();
int minutes = date.getMinutes();
int hours = date.getHours();

int time = ((seconds >> 1) & 0x001F) + ((minutes << 5) & 0x07E0) + ((hours << 11) & 0xF800);
return shuffleShort(time);
}

/**
* Converts the date in a Date object to a <tt>.zip</tt> date.
* @param date the Date object.
* @return the <tt>.zip</tt> date.
**/

static int zipDate(Date date) {
int day = date.getDate();
int month = date.getMonth() + 1;
int year = date.getYear() - 80;

int newDate = (day & 0x001F) + ((month << 5) & 0x01E0) + ((year << 9) & 0xFE00);
return shuffleShort(newDate);
}

/**
* Shuffles a short from <tt>.zip</tt> byte order to <tt>.java</tt> byte order
* or vice versa.
* @param val the short to shuffle.
**/
static int shuffleShort(int val) {
return ((val & 0x00FF) << 8) + ((val >> 8) & 0x00FF);
}


JHLZip I think was what the original code was called, I lost track of where it might currently be available.
TRZ or Transparent Random Zip is what my modified version was called. This particular code though I think saw no modifications.


Mike Hall        hallmike at att dot net
http://www.geocities.com/mik3hall
http://sourceforge.net/projects/macnative



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Compilation date [closed] (From: "Patrick Lacour" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.