Added backup-nexttape Work in Progress
This commit is contained in:
52
autoload/assono-backup-nexttape.nu
Normal file
52
autoload/assono-backup-nexttape.nu
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
export def lumen-assono-backup-nexttape [dateinput: datetime]: nothing -> nothing {
|
||||||
|
$dateinput | get-backup-string
|
||||||
|
print 'Next Required Tape:'
|
||||||
|
print $'($dateinput | get-backup-string)'
|
||||||
|
print ''
|
||||||
|
print 'Tapes after that:'
|
||||||
|
|
||||||
|
..9 | each {|i|
|
||||||
|
print $'($i): (($dateinput + ((7 * $i) | into duration -u day)) | get-backup-string)'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def get-backup-string []: datetime -> string {
|
||||||
|
print $in
|
||||||
|
let saturdayOfMonth = $in | get-week-of-month 6
|
||||||
|
let monthOfQuarter = $in | get-month-of-quarter
|
||||||
|
let quarter = $in | get-quarter
|
||||||
|
let year = $in | get-year
|
||||||
|
if ($saturdayOfMonth == 1) {
|
||||||
|
if ($monthOfQuarter == 1) {
|
||||||
|
if ($quarter == 1) {
|
||||||
|
$'TapeLTO5-Y($year)'
|
||||||
|
} else {
|
||||||
|
$'TapeLTO5-Q($quarter)'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$'TapeLTO5-M($monthOfQuarter)'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$'TapeLTO5-W($saturdayOfMonth)'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def get-week-of-month [weekdayindex: int]: datetime -> int {
|
||||||
|
($in + ($weekdayindex | into duration -u day) - (($in | format date '%w' ) | into duration -u day)) | format date %w
|
||||||
|
}
|
||||||
|
|
||||||
|
def get-month-of-quarter []: datetime -> int {
|
||||||
|
mut month = $in | format date '%m' | into int
|
||||||
|
while ($month > 3) {
|
||||||
|
$month -= 3
|
||||||
|
}
|
||||||
|
$month
|
||||||
|
}
|
||||||
|
|
||||||
|
def get-quarter []: datetime -> int {
|
||||||
|
(($in | format date '%m') | into int) / 3 | math ceil
|
||||||
|
}
|
||||||
|
|
||||||
|
def get-year []: datetime -> int {
|
||||||
|
$in | format date '%Y'
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user