fat和ntfs文件的时间转换为年月日的时间

本文探讨了NTFS文件系统中时间戳的表示方式,它以1601年1月1日为起点的100ns计数。为了将这种时间转换为可读的年月日,需要编写转换函数,尤其要考虑闰年的影响。代码经过测试,适用于1999年至2015年间的文件,转换12月和1月文件时需格外小心。
摘要由CSDN通过智能技术生成
客户突然说需要在项目上能显示完整的文件的时间属性, 比如最后修改时间.
NTFS的实现由于时间比较紧,就没有到网上找找看有没有已经实现的算法.如果谁知道有已经实现的算法的话请不吝告知啊.谢谢.

fat的就比较简单,在dir entry中,找到相关字段,进行以为操作即可,然后加上1980年的偏移就ok.
fno->fileinfo.year = (fno->fileinfo.fdate >> 9) + 1980;

fno->fileinfo.month = (fno->fileinfo.fdate >> 5) & 15;

fno->fileinfo.day = fno->fileinfo.fdate & 31;

fno->fileinfo.hour = (fno->fileinfo.ftime >> 11);

fno->fileinfo.minute = (fno->fileinfo.ftime >> 5) & 63,

fno->fileinfo.second = (fno->fileinfo.ftime & 31) * 2;

下面是fat的white paper的内容:
Date and Time Formats
Many FAT file systems do not support Date/Time other than DIR_WrtTime and DIR_WrtDate.
For this reason, DIR_CrtTimeMil, DIR_CrtTime, DIR_CrtDate, and DIR_LstAccDate are actually optional fields.
DIR_WrtTime and DIR_WrtDate must be supported, however. If the other da
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值