@@ -125,7 +125,8 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index
125
125
bool isHidden = !!(disk -> type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT );
126
126
bool isReadOnly = !!(disk -> type & FF_DISK_VOLUME_TYPE_READONLY_BIT );
127
127
128
- uint64_t duration = ffTimeGetNow () - disk -> createTime ;
128
+ uint64_t now = ffTimeGetNow ();
129
+ uint64_t duration = now - disk -> createTime ;
129
130
uint32_t milliseconds = (uint32_t ) (duration % 1000 );
130
131
duration /= 1000 ;
131
132
uint32_t seconds = (uint32_t ) (duration % 60 );
@@ -136,6 +137,33 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index
136
137
duration /= 24 ;
137
138
uint32_t days = (uint32_t ) duration ;
138
139
140
+ time_t past_s = (time_t ) (disk -> createTime / 1000 );
141
+ struct tm past_tm ;
142
+ #ifdef _WIN32
143
+ localtime_s (& past_tm , & past_s );
144
+ #else
145
+ localtime_r (& past_s , & past_tm );
146
+ #endif
147
+
148
+ time_t now_s = (time_t ) (now / 1000 );
149
+ struct tm now_tm ;
150
+ #ifdef _WIN32
151
+ localtime_s (& now_tm , & now_s );
152
+ #else
153
+ localtime_r (& now_s , & now_tm );
154
+ #endif
155
+
156
+ uint32_t years = (uint32_t ) (now_tm .tm_year - past_tm .tm_year );
157
+ if (now_tm .tm_yday < past_tm .tm_yday )
158
+ years -- ;
159
+ past_tm .tm_year += years ;
160
+ uint32_t gap_s = (uint32_t ) (now_s - mktime (& past_tm ));
161
+ uint32_t daysOfYear = gap_s / (24 * 60 * 60 );
162
+
163
+ uint32_t pastYear = past_tm .tm_year + 1900 ;
164
+ bool isLeapYear = (pastYear % 4 == 0 && pastYear % 100 != 0 ) || (pastYear % 400 == 0 );
165
+ double yearsFraction = (double ) daysOfYear / (isLeapYear ? 366 : 365 ) + years ;
166
+
139
167
FF_PRINT_FORMAT_CHECKED (key .chars , 0 , & options -> moduleArgs , FF_PRINT_TYPE_NO_CUSTOM_KEY , ((FFformatarg []) {
140
168
FF_FORMAT_ARG (usedPretty , "size-used" ),
141
169
FF_FORMAT_ARG (totalPretty , "size-total" ),
@@ -158,6 +186,9 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index
158
186
FF_FORMAT_ARG (milliseconds , "milliseconds" ),
159
187
FF_FORMAT_ARG (disk -> mountpoint , "mountpoint" ),
160
188
FF_FORMAT_ARG (disk -> mountFrom , "mount-from" ),
189
+ FF_FORMAT_ARG (years , "years" ),
190
+ FF_FORMAT_ARG (daysOfYear , "days-of-year" ),
191
+ FF_FORMAT_ARG (yearsFraction , "years-fraction" ),
161
192
}));
162
193
}
163
194
}
@@ -523,6 +554,9 @@ static FFModuleBaseInfo ffModuleInfo = {
523
554
{"Milliseconds after creation" , "milliseconds" },
524
555
{"Mount point / drive letter" , "mountpoint" },
525
556
{"Mount from (device path)" , "mount-from" },
557
+ {"Years integer after creation" , "years" },
558
+ {"Days of year after creation" , "days-of-year" },
559
+ {"Years fraction after creation" , "years-fraction" },
526
560
}))
527
561
};
528
562
0 commit comments