Great additions Aldebaran!

DateTime can do date arithmetic as simply as:

my $dt = DateTime->new( year => 2021, month => 4, day => 5, hour => 2, time_zone => 'Africa/Nairobi', ); # or, create a DateTime object from an ISO timestring my $isostr = '2021-10-11T11:13:57'; my $dt = DateTime::Format::ISO8601->parse_datetime($isostr); # add a second to what $dt currently holds $dt->add(seconds => 1);

Regarding your other questions, I have no clue about celestial mechanics. Nonetheless I have whipped up a Perl sub to get you the elevation given coordinates. It uses a site which I am not sure if they would like people using their services in this way. So with that in mind:

# usage: # my $elevation = get_elevation_from_coordinates(15.6325, 38.245833, 0 +); sub get_elevation_from_coordinates { my ($lat, $lon, $debug) = @_; $debug //= 0; my $ua = LWP::UserAgent->new( agent => 'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100 +101 Firefox/78.0', ); my $response; my $payload = 'latitude='.$lat .'&longitude='.$lon .'&application_max_assets_mtime=1559625591' ; my $payloadlen = length($payload); # this request was translated from Curl command-line # by [Corion]'s https://corion.net/curl2lwp.psgi my $req = HTTP::Request->new( 'POST' => 'https://www.mapcoordinates.net/admin/component/edit +/Vpc_MapCoordinates_Advanced_GoogleMapCoords_Component/Component/json +-get-elevation', [ 'Connection' => 'keep-alive', 'Accept' => '*/*', 'Accept-Encoding' => 'gzip, x-gzip, deflate, x-bzip2, bzip2', 'Accept-Language' => 'en-US,en;q=0.5', # 'Host' => 'www.mapcoordinates.net:443', 'Referer' => 'https://www.mapcoordinates.net/en', 'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) +Gecko/20100101 Firefox/78.0', 'Content-Length' => $payloadlen, 'Content-Type' => 'application/x-www-form-urlencoded; charse +t=UTF-8', 'DNT' => '1', 'Origin' => 'https://www.mapcoordinates.net', 'X-Requested-With' => 'XMLHttpRequest' ], $payload ); die "call to HTTP::Request has failed" unless $req; if( $debug > 0 ){ print "$0 : $payload\n$0 : sending above payload +, of $payloadlen bytes...\n" } $response = $ua->request($req); die "Error fetching: ".$response->status_line unless $response->is_success; my $content = $response->decoded_content; my $data = Data::Roundtrip::json2perl($content); die "failed to parse received data:\n$content\n" unless exists $data->{'elevation'}; return $data->{'elevation'}; }

bw, bliako


In reply to Re^4: Moon phase on historical events by bliako
in thread Moon phase on historical events by bliako

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.