Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: making a list that includes timed events

by hippo (Bishop)
on Dec 15, 2020 at 10:18 UTC ( [id://11125223]=note: print w/replies, xml ) Need Help??


in reply to making a list that includes timed events

I searched for Hanukkah on cpan and got no results.

Always worth a grep. This reveals DateTime::Event::Jewish which, although it doesn't solve your present problem, might be useful for related tasks.


🦛

Replies are listed 'Best First'.
Re^2: making a list that includes timed events
by Aldebaran (Curate) on Dec 15, 2020 at 19:49 UTC
    This reveals DateTime::Event::Jewish

    Instead of leaving out the vowels, they left out the code there. I went ahead and think I succeeded at rolling my own:

    $ ./3.2.list.pl ./3.2.list.pl 15 December Tue Sun set is Wed Dec 16 00:27:40 2020 UT obs time is 1608078460 Planet Azimuth Elevation Jupiter 251.372775875378 35.8473305794901 Saturn 251.852813297588 35.3104653817931 diff: 0.480037422209762 -0.536865197696955 1607732818 0 Sun set is Sat Dec 12 00:26:58 2020 diff: 0.480037422209762 -0.536865197696955 begin perlukkah in epoch seconds 1607732818 set alarm for 8:30 --one snooze max meds am brekkies stretch rehab exe +rcises meditation ablutions journal sing a song this is the 6 th the +day of perlukkah observe planets at this epoch time: 34.82 it is 5 da +ys until jup-sat conjunction meds pm new_name is November_16_2020 save_file is /home/hogan/Documents/hogan/my_data/November_16_2020.pdf $ cat 3.2.list.pl #!/usr/bin/env perl use v5.14; use Path::Class; use PDF::API2; my $path = '/home/hogan/Documents/hogan/my_data'; my @months = qw(January February March April May June July August September October November December); my @days = qw(Sun Mon Tue Wed Thu Fri Sat Sun); ### update for perlukkah 2020 # add grownup logging use Log::Log4perl; my $file = '/home/hogan/Documents/hogan/logs/4.log4perl.txt'; unlink $file or warn "Could not unlink $file: $!"; my $log_conf4 = "/home/hogan/Documents/hogan/logs/conf_files/4.conf"; Log::Log4perl::init($log_conf4); #info my $logger = Log::Log4perl->get_logger(); $logger->info("$0"); ## populate an array with ephemeral objects # order the same as fourmilab my @ephem = qw(Sun Mercury Venus Moon Mars Jupiter Saturn Uranus Neptu +ne Pluto); #### unaltered my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(); print "$mday $months[$mon] $days[$wday]\n"; my $day = $mday + 1; my $yr = $year + 1900; my $header = "List for $days[$wday+1], $months[$mon -1] $day, $yr"; my $pdf = PDF::API2->new( width => 595, # A4 dimensions in point height => 842, # 1 point = 1/72 inch ); #### # clack my $lat = 45.4; my $long = -122.5; use Astro::Coord::ECI; use Astro::Coord::ECI::Sun; use Astro::Coord::ECI::Utils qw{deg2rad}; $lat = deg2rad($lat); # convert for deg to Radians $long = deg2rad($long); # " my $alt = .5; # Kilometers <- looks spuri +ous my $sun = Astro::Coord::ECI::Sun->new(); my $sta = Astro::Coord::ECI->universal( time() )->geodetic( $lat, $lon +g, $alt ); my ( $time, $rise ) = $sta->next_elevation($sun); $logger->info( "Sun @{[$rise ? 'rise' : 'set']} is ", scalar gmtime $time, " UT" ); my $obs_time = $time; $logger->info("obs time is $obs_time"); # Use Astro:: to get some scalars use Time::Piece; use Astro::Coords; use Astro::Telescope; my $out_string; $out_string = qq/Planet\tAzimuth\t\t\tElevation/; $logger->info("$out_string"); my ( @a, @b ); for my $name (qw/Jupiter Saturn/) { my $planet = Astro::Coords->new( planet => $name ); $planet->datetime( Time::Piece->new ); $planet->telescope( Astro::Telescope->new( Name => 'clackamas', Long => $lat, Lat => $long, Alt => $alt ) ); my $az = $planet->az( format => 'deg' ); my $el = $planet->el( format => 'deg' ); push @a, $az; push @b, $el; $out_string = qq/$name\t$az\t $el/; $logger->info("$out_string"); } my $delta_a = $a[1] - $a[0]; my $delta_b = $b[1] - $b[0]; $out_string = qq/diff:\t$delta_a\t $delta_b/; $logger->info("$out_string"); ### roll our own start to hanukkah 2020 for clack # create dt object for afternoon use DateTime; my $dt = DateTime->new( year => 2020, month => 12, day => 11, hour => 14, time_zone => 'America/Los_Angeles', ); my $afternoon_integer = $dt->epoch; my $sun2 = Astro::Coord::ECI::Sun->new(); my $sta = Astro::Coord::ECI->universal($afternoon_intege +r) ->geodetic( $lat, $long, $alt ); my ( $time2, $rise2 ) = $sta->next_elevation($sun2); $logger->info("$time2 $rise2"); $logger->info( "Sun @{[$rise2 ? 'rise' : 'set']} is ", scalar gmtime $time2, " UT\n" ); $logger->info("$out_string"); my $ansatz = $time2; $logger->info("begin perlukkah in epoch seconds $ansatz"); #### unaltered my $page = $pdf->page; my $txt = $page->text; my $font = $pdf->corefont('Times-Roman'); $txt->font( $font, 32 ); $txt->translate( 100, 650 ); $txt->text( $header, -encoding => 'utf8' ); #### # close integer values to begin stub out code with: my ( $m, $n, $beo_zeit ) = ( 5, 6, 34.82 ); my @task = ( 'set alarm for 8:30 --one snooze max', 'meds am', 'brekkies', 'stretch', 'rehab exercises', 'meditation', 'ablutions', 'journal', 'sing a song', "this is the $n th the day of perlukkah", "observe planets at this epoch time: $beo_zeit", "it is $m days until jup-sat conjunction", 'meds pm', ); $logger->info("@task"); #### unaltered my $line = $page->gfx; $txt->font( $font, 20 ); my $vspace = 70; for my $i ( 0 .. $#task ) { my $linepos = 500 - ( $i * $vspace ); my $msg = '[ ] ' . $task[$i]; drawline( $line, $linepos ); $txt->translate( 70, $linepos + 10 ); $txt->text($msg); } my $new_name = join( '_', $months[ $mon - 1 ], $day, $yr ); say "new_name is $new_name"; my $save_file = file( $path, "$new_name.pdf" ); say "save_file is $save_file"; $pdf->saveas("$save_file"); sub drawline { my ( $line, $y ) = @_; my $x1 = 50; my $x2 = 550; $line->linewidth(3); $line->move( $x1, $y ); $line->line( $x2, $y ); $line->stroke; } #### unaltered __END__ $

    The .pdf still doesn't have the entries with double quotes and interpolations.(?)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11125223]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (11)
As of 2024-03-28 09:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found