Libraryless. Click here for Pure Java version (10856L/60K).
sclass BackupFileAge { // minutes (last group) are optional settable S pattern = "^(.*)\\.backup(2\\d\\d\\d)(\\d\\d)(\\d\\d)-(\\d\\d)(\\d*)$"; settable S fileName; settable TimeZone timeZone = defaultTimeZone(); settable long currentTime = now(); S originalName; int year; int month; int day; int hour; int minute; long time; gettable double ageInDays; bool parse() { var pat = regexp(pattern); var matcher = pat.matcher(fileName); if (!matcher.find()) false; originalName = matcher.group(1); year = matcherInt(matcher, 2); month = matcherInt(matcher, 3); day = matcherInt(matcher, 4); hour = matcherInt(matcher, 5); minute = matcherInt(matcher, 6); time = timestampFromYMDHM(year, month, day, hour, minute, timeZone); ageInDays = ((currentTime-time)/1000.0/60/60/24; true; } }
Began life as a copy of #1011269
download show line numbers debug dex old transpilations
Travelled to 1 computer(s): mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1038774 |
Snippet name: | BackupFileAge - calculates how old a backup file is in days from the file name |
Eternal ID of this version: | #1038774/8 |
Text MD5: | 9c1fc30477f690e1fd7ab47abcc467ee |
Transpilation MD5: | dd6da15bfd2d3d24cb5143f9bb12537a |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2025-04-20 18:25:53 |
Source code size: | 905 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 29 / 79 |
Version history: | 7 change(s) |
Referenced in: | #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167) #1038775 - test_BackupFileAge |