Rob, Chris & Co: I'm starting a new thread in case others are working with AppleCommander. I found a few problems with Pascal dates in v1.2.3. In AppleUtil.getPascalDate, the comments were correct, but the masks and shift sizes were off. Also, Pascal months start at one, while java starts at zero. /** * Extract a Pascal date from the buffer.
* Bits 0-3: month (1-12)
* Bits 4-8: day (1-31)
* Bits 9-15: year (0-99) */ public static Date getPascalDate(byte[] buffer, int offset) { int pascalDate = getWordValue(buffer, offset); int month = pascalDate & 0x000f - 1; int day = (pascalDate & 0x01f0) >> 4; int year = (pascalDate & 0xfe00) >> 9; if (year < 50) year+= 2000; if (year < 100) year+= 1900; GregorianCalendar gc = new GregorianCalendar(year, month, day); return gc.getTime(); } May I propose using the SimpleDateFormat "dd-MMM-yy" in PascalFileEntry.getFileColumnData. It's what the Pascal Filer uses. In the same vein, I'd advocate adding a colon to the volume name in PascalFormatDisk.getDiskName. Again, it's what Pascal users might expect. The result looks like this: APPLE1: 09-Nov-80 032 datafile SYSTEM.APPLE 22-Sep-80 041 codefile SYSTEM.PASCAL 04-May-79 001 datafile SYSTEM.MISCINFO 24-Sep-80 047 codefile SYSTEM.EDITOR 18-Sep-80 028 codefile SYSTEM.FILER 19-Sep-80 034 datafile SYSTEM.LIBRARY 14-Jul-79 002 datafile SYSTEM.CHARSET 01-Sep-80 014 datafile SYSTEM.SYNTAX Pascal format; 38400 bytes free; 104960 bytes used. John ---- jmatthews at wright dot edu www dot wright dot edu/~john.matthews/ "John B. Matthews" wrote in news:nospam- 9A321F.16303129082003@clmboh1-nws3.columbus.rr.com: > In AppleUtil.getPascalDate, the comments were correct, but the > masks and shift sizes were off. Also, Pascal months start at > one, while java starts at zero. > > /** > * Extract a Pascal date from the buffer.
> * Bits 0-3: month (1-12)
> * Bits 4-8: day (1-31)
> * Bits 9-15: year (0-99) > */ > public static Date getPascalDate(byte[] buffer, int offset) { > int pascalDate = getWordValue(buffer, offset); > int month = pascalDate & 0x000f - 1; > int day = (pascalDate & 0x01f0) >> 4; > int year = (pascalDate & 0xfe00) >> 9; > if (year < 50) year+= 2000; > if (year < 100) year+= 1900; > GregorianCalendar gc = > new GregorianCalendar(year, month, day); > return gc.getTime(); > } Sound of a hand smacking my forehead! I *just* reviewed it too. The set is probably wrong too. > May I propose using the SimpleDateFormat "dd-MMM-yy" in > PascalFileEntry.getFileColumnData. It's what the Pascal Filer > uses. That should be fine. My only caveat will be when I compile it with GCC/GCJ. It should be there, but it also may not be. > In the same vein, I'd advocate adding a colon to the > volume name in PascalFormatDisk.getDiskName. Again, it's what > Pascal users might expect. Sounds logical. > The result looks like this: > > APPLE1: > 09-Nov-80 032 datafile SYSTEM.APPLE > 22-Sep-80 041 codefile SYSTEM.PASCAL > 04-May-79 001 datafile SYSTEM.MISCINFO > 24-Sep-80 047 codefile SYSTEM.EDITOR > 18-Sep-80 028 codefile SYSTEM.FILER > 19-Sep-80 034 datafile SYSTEM.LIBRARY > 14-Jul-79 002 datafile SYSTEM.CHARSET > 01-Sep-80 014 datafile SYSTEM.SYNTAX > Pascal format; 38400 bytes free; 104960 bytes used. Looks beautiful - thanks! -Rob In article , Rob Greene wrote: > "John B. Matthews" wrote in news:nospam- > 9A321F.16303129082003@clmboh1-nws3.columbus.rr.com: > > > In AppleUtil.getPascalDate, the comments were correct, but the > > masks and shift sizes were off. Also, Pascal months start at > > one, while java starts at zero. > > > > /** > > * Extract a Pascal date from the buffer.
> > * Bits 0-3: month (1-12)
> > * Bits 4-8: day (1-31)
> > * Bits 9-15: year (0-99) > > */ > > public static Date getPascalDate(byte[] buffer, int offset) { > > int pascalDate = getWordValue(buffer, offset); > > int month = pascalDate & 0x000f - 1; > > int day = (pascalDate & 0x01f0) >> 4; > > int year = (pascalDate & 0xfe00) >> 9; > > if (year < 50) year+= 2000; > > if (year < 100) year+= 1900; > > GregorianCalendar gc = > > new GregorianCalendar(year, month, day); > > return gc.getTime(); > > } > > Sound of a hand smacking my forehead! I *just* reviewed it too. > > > The set is probably wrong too. Good point! /** * Set a Pascal data to the buffer.
* Bits 0-3: month (1-12)
* Bits 4-8: day (1-31)
* Bits 9-15: year (0-99) */ public static void setPascalDate(byte[] buffer, int offset, Date date) { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(date); int month = gc.get(GregorianCalendar.MONTH) + 1; int day = gc.get(GregorianCalendar.DAY_OF_MONTH); int year = gc.get(GregorianCalendar.YEAR) % 100; int pascalDate = (month & 0x000f) | ((day << 4) & 0x01f0) | ((year << 9) & 0xfe00); setWordValue(buffer, offset, pascalDate); } > -Rob John ---- jmatthews at wright dot edu www dot wright dot edu/~john.matthews/