Finished assono-backup-nexttape
This commit is contained in:
@@ -1,25 +1,24 @@
|
|||||||
export def lumen-assono-backup-nexttape [dateinput: datetime]: nothing -> nothing {
|
export def lumen-assono-backup-nexttape [dateinput: datetime]: nothing -> nothing {
|
||||||
$dateinput | get-backup-string
|
|
||||||
print 'Next Required Tape:'
|
print 'Next Required Tape:'
|
||||||
print $'($dateinput | get-backup-string)'
|
print $'($dateinput | get-backup-string)'
|
||||||
print ''
|
print ''
|
||||||
print 'Tapes after that:'
|
print 'Tapes after that:'
|
||||||
|
|
||||||
..9 | each {|i|
|
1..9 | each {|i|
|
||||||
print $'($i): (($dateinput + ((7 * $i) | into duration -u day)) | get-backup-string)'
|
print $'($i): (($dateinput + ((7 * $i) | into duration -u day)) | get-backup-string)'
|
||||||
}
|
} | ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
def get-backup-string []: datetime -> string {
|
def get-backup-string []: datetime -> string {
|
||||||
print $in
|
let backupDay = $in - ($in | format date '%w' | into duration -u day) + 6day
|
||||||
let saturdayOfMonth = $in | get-week-of-month 6
|
let saturdayOfMonth = $backupDay | get-week-of-month
|
||||||
let monthOfQuarter = $in | get-month-of-quarter
|
let monthOfQuarter = $backupDay | get-month-of-quarter
|
||||||
let quarter = $in | get-quarter
|
let quarter = $backupDay | get-quarter
|
||||||
let year = $in | get-year
|
let year = $backupDay | get-year
|
||||||
if ($saturdayOfMonth == 1) {
|
if ($saturdayOfMonth == 1) {
|
||||||
if ($monthOfQuarter == 1) {
|
if ($monthOfQuarter == 1) {
|
||||||
if ($quarter == 1) {
|
if ($quarter == 1) {
|
||||||
$'TapeLTO5-Y($year)'
|
$'TapeLTO5-Y(($year | into string | str substring 3..))'
|
||||||
} else {
|
} else {
|
||||||
$'TapeLTO5-Q($quarter)'
|
$'TapeLTO5-Q($quarter)'
|
||||||
}
|
}
|
||||||
@@ -31,9 +30,11 @@ def get-backup-string []: datetime -> string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def get-week-of-month [weekdayindex: int]: datetime -> int {
|
def get-week-of-month []: datetime -> int {
|
||||||
($in + ($weekdayindex | into duration -u day) - (($in | format date '%w' ) | into duration -u day)) | format date %w
|
let firstDay = ($in - ($in | format date '%d' | into duration -u day) + 1day)
|
||||||
}
|
let $firstSpecificDay = $firstDay + (((($in | format date '%w' | into int) + 7 - ($firstDay | format date '%w' | into int)) mod 7) | into duration -u day)
|
||||||
|
((($in - $firstSpecificDay) | into int | into datetime | format date '%d' | into int) / 7 | math floor) + 1
|
||||||
|
}
|
||||||
|
|
||||||
def get-month-of-quarter []: datetime -> int {
|
def get-month-of-quarter []: datetime -> int {
|
||||||
mut month = $in | format date '%m' | into int
|
mut month = $in | format date '%m' | into int
|
||||||
|
|||||||
Reference in New Issue
Block a user