{"action":"created","issue":{"url":"https://api.github.com/repos/Dual-Life/Time-Piece/issues/42","repository_url":"https://api.github.com/repos/Dual-Life/Time-Piece","labels_url":"https://api.github.com/repos/Dual-Life/Time-Piece/issues/42/labels{/name}","comments_url":"https://api.github.com/repos/Dual-Life/Time-Piece/issues/42/comments","events_url":"https://api.github.com/repos/Dual-Life/Time-Piece/issues/42/events","html_url":"https://github.com/Dual-Life/Time-Piece/issues/42","id":340041689,"node_id":"MDU6SXNzdWUzNDAwNDE2ODk=","number":42,"title":"Time::Piece overloading will not accept overloaded objects","user":{"login":"mla","id":44186,"node_id":"MDQ6VXNlcjQ0MTg2","avatar_url":"https://avatars1.githubusercontent.com/u/44186?v=4","gravatar_id":"","url":"https://api.github.com/users/mla","html_url":"https://github.com/mla","followers_url":"https://api.github.com/users/mla/followers","following_url":"https://api.github.com/users/mla/following{/other_user}","gists_url":"https://api.github.com/users/mla/gists{/gist_id}","starred_url":"https://api.github.com/users/mla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mla/subscriptions","organizations_url":"https://api.github.com/users/mla/orgs","repos_url":"https://api.github.com/users/mla/repos","events_url":"https://api.github.com/users/mla/events{/privacy}","received_events_url":"https://api.github.com/users/mla/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":17,"created_at":"2018-07-10T23:32:51Z","updated_at":"2018-08-18T16:17:29Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Discovered that bignum does not play nice with Time::Piece. Getting \"Invalid rhs of addition: 46800\" errors when the seconds value is a Math::BigInt::Lite instance.\r\n\r\nExample:\r\n\r\n```perl\r\n#!/usr/bin/env perl\r\n\r\n  use strict;\r\n  use warnings;\r\n  use Time::Piece qw/ localtime /;\r\n  use Time::Seconds;\r\n\r\n  my $d1 = localtime;\r\n  print \"\\$d1 is a \", ref($d1), \"\\n\";\r\n\r\n  my $secs = 46800;\r\n  print \"\\$secs is a \", (ref($secs) || 'scalar') , \"\\n\";\r\n\r\n  my $d2 = $d1 + $secs;\r\n  print \"sum is: $d2\\n\\n\";\r\n\r\n  use bignum;\r\n\r\n  $secs = 46800;\r\n  print \"\\$secs is a \", (ref($secs) || 'scalar') , \"\\n\";\r\n\r\n  $d2 = $d1 + $secs;\r\n  print \"sum is: $d2\\n\";\r\n```\r\n\r\nThere's an explicit check for a ref on rhs, in which case the value\r\nis rejected. From Time::Piece 1.3204:\r\n\r\n```perl\r\n  sub add {\r\n      my $time = shift;\r\n      my $rhs = shift;\r\n      if (UNIVERSAL::isa($rhs, 'Time::Seconds')) {\r\n          $rhs = $rhs->seconds;\r\n      }\r\n      croak \"Invalid rhs of addition: $rhs\" if ref($rhs);\r\n\r\n      return $time->_mktime(($time->epoch + $rhs), $time->[c_islocal]);\r\n  }\r\n```\r\n\r\nI can force the BigInt to an int, of course, but would be nice if it was more transparent. I ran into this when a \"use bignum\" was added to a module and it unexpectedly broke some of the date handling.\r\n\r\nI have a proof-of-concept here:\r\nhttps://github.com/Dual-Life/Time-Piece/compare/master...mla:feature/blessed?expand=1\r\n\r\nThe _mktime logic is a bit tricky, since Time::Piece is itself a blessed array ref. So it has to know when it should or shouldn't try to expand the contents of $time.\r\n\r\nMy version seems to be passing all tests and satisfies my use-case. I haven't tested it for all overloaded operators or added any tests. It also requires Scalar::Util now; not sure if it's a problem to add that dependency to a core module or not.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Dual-Life/Time-Piece/issues/comments/414069266","html_url":"https://github.com/Dual-Life/Time-Piece/issues/42#issuecomment-414069266","issue_url":"https://api.github.com/repos/Dual-Life/Time-Piece/issues/42","id":414069266,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDA2OTI2Ng==","user":{"login":"smith153","id":796628,"node_id":"MDQ6VXNlcjc5NjYyOA==","avatar_url":"https://avatars2.githubusercontent.com/u/796628?v=4","gravatar_id":"","url":"https://api.github.com/users/smith153","html_url":"https://github.com/smith153","followers_url":"https://api.github.com/users/smith153/followers","following_url":"https://api.github.com/users/smith153/following{/other_user}","gists_url":"https://api.github.com/users/smith153/gists{/gist_id}","starred_url":"https://api.github.com/users/smith153/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smith153/subscriptions","organizations_url":"https://api.github.com/users/smith153/orgs","repos_url":"https://api.github.com/users/smith153/repos","events_url":"https://api.github.com/users/smith153/events{/privacy}","received_events_url":"https://api.github.com/users/smith153/received_events","type":"User","site_admin":false},"created_at":"2018-08-18T16:17:29Z","updated_at":"2018-08-18T16:17:29Z","author_association":"COLLABORATOR","body":"Pushed version 1.33 to cpan"}}
{"actor":{"display_login":"smith153"}}