Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env perl
- use v5.10;
- no strict;
- use POSIX(strftime);
- use Time::Local(timelocal);
- use Time::HiRes qw(gettimeofday usleep);
- $| = 1;
- system('tput civis && clear && echo && echo');
- @CLOCKS = qw [
- π π§ π π π π π π
- π π π π π π‘ π π’
- π π£ π π€ π π₯ π π¦
- ];
- $day_of_week = strftime "%u", localtime;
- $wage_hour = $day_of_week =~ /[67]/ ? 60 : 45;
- if (@ARGV) {
- ($start_time = $ARGV[0]) =~ s/[:,.\s]//g;
- ($h, $m, $s) = ($start_time, 0, 0) if $start_time =~ (/^..?$/);
- ($h, $m, $s) = ($1, $2, 0) if $start_time =~ (/^(..)(..)$/);
- ($h, $m, $s) = ($1, $2, $3) if $start_time =~ (/^(..)(..)(..)$/);
- } else {
- ($h, $m, $s) = $day_of_week =~ /[67]/ ? (10, 0, 0) : (18, 0, 0);
- }
- $start_ts = timelocal($s, $m, $h, (localtime)[3 .. 5]);
- $now_ts = timelocal(localtime);
- $start_ts -= 24 * 3600 if $start_ts > $now_ts;
- while (1) {
- $now_time = strftime "%H:%M:%S", localtime;
- ($now_s, $now_ts_mus) = gettimeofday();
- $total_ts_mus = ($now_s - $start_ts) * 1_000_000 + $now_ts_mus;
- $total_ts_h = $total_ts_mus / 1_000_000 / 3600;
- $wage_tot = $total_ts_h * $wage_hour;
- $clock_idx = $now_s % @CLOCKS;
- printf "\r%s$now_time π¨ε·²ε η%.1fε°ζΆ π°θΎθ¦θ΄Ή%.4f",
- $CLOCKS[$clock_idx], $total_ts_h, $wage_tot;
- usleep(5_000);
- }
Add Comment
Please, Sign In to add comment