Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. # Calculates day of the week for a givien date
  2. # Month: jan,feb ... nov,dec (must be lower-case)
  3. # Day: 1 - 31
  4. # Year: 1583 - ...
  5. # mmm/dd/yyyy same format as [/system clock get date]
  6. # (ex. feb/19/2012)
  7. # by melboyscout (melboyscout [at] gmail.com)
  8. :local date [/system clock get date]
  9. # Math Calculation here
  10. :global result ""
  11. :global resultnmbr ""
  12. :local months [:toarray "jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec"]
  13. :local daytbl [:toarray "sun,mon,tue,wed,thu,fri,sat"]
  14. :local daynumber [:toarray "7,1,2,3,4,5,6"]
  15. :local month [:pick $date 0 3]
  16. :local day [:pick $date 4 6]
  17. :local dayc [:pick $date 5 6]
  18. :local year [:pick $date 7 11]
  19. # if the first char is a 0 (zero) only read last char, else script fails
  20. :if ([:pick $date 4 5] = 0) do={ :set day ($dayc)}
  21. :local sum 0
  22. :local aaa 0
  23. :local yyy 0
  24. :local mmm 0
  25. :local nmonth 1
  26. :for mindex from=0 to=[:len $months] do={
  27. :if ([:pick $months $mindex] = $month) do={:set nmonth ($mindex + 1) }
  28. }
  29. :set aaa ((14 - $nmonth) / 12)
  30. :set yyy ($year - $aaa)
  31. :set mmm ($nmonth + 12 * $aaa - 2)
  32. :set sum (7000 + $day + $yyy + ($yyy / 4) - ($yyy / 100) + ($yyy / 400) + ((31 * $mmm) / 12))
  33. :set sum ($sum - (($sum / 7) * 7))
  34. :set result [:pick $daytbl $sum]
  35. :set resultnmbr [:pick $daynumber $sum]
  36. :log info "Today is $result"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement