Comments (6)
from datetime.pm.
Yes, I think this would be possible. We'd need to check that @_ == 1
and that $_[0]
is a valid Num
. Are you up for writing a PR?
from datetime.pm.
Are you up for writing a PR?
My first thought was "yeah", that should be easy — as you say,we just need to check @_ and valid number. How hard can that be? Then I looked at the code for from_epoch
with its validation etc, and remembering there are other options allowed, so it's not such a quick fix, for me at least.
I've put it on my perl todo list, but TBH there are a lot of things ahead of it, so realistically not likely to happen any time soon, sadly.
from datetime.pm.
@autarch I've had a look at this but can't figure out how to validate with Params::ValidationCompiler
, any pointers?
This seems to work:
my %p = $_[0] =~ /^\d+$/ ? ( epoch => $_[0] ) : $validator->(@_);
Is there a smart way to work this into the current validator that I'm missing, or is it possible to have the validator not die, then I could use two separate validators?
from datetime.pm.
Added in 1.56
from datetime.pm.
Yay! Thanks.
from datetime.pm.
Related Issues (20)
- Implement `use DateTime ':hires'` HOT 1
- Do I miss something with timezones? HOT 2
- Improve add_duration HOT 2
- Add ability to lock/unlock DateTime objects through methods, which when locked causes an exception on in-place modification HOT 2
- calculated last day of month wrong HOT 2
- -Inf/Inf should be formatted as -infinity/infinity HOT 8
- constructor will not accept second => 60 HOT 3
- Can not compare two datetime objects HOT 3
- DateTime->from_epoch( epoch => 0 ) HOT 5
- Tests fail when PERL_DATETIME_DEFAULT_TZ is set on system HOT 2
- Typos in recent Duration documentation update HOT 1
- datetime.perl.org not found HOT 1
- DateTime::Duration::in_units('days') should not return completely wrong answers for durations over 1 month HOT 19
- Truncate ignores DST flag. Bug or intended behavior? HOT 3
- Europe/Dublin DST flag is backwards? HOT 3
- Clarify pod "our $App::LocalTZ = ..." (not legal Perl syntax) HOT 1
- [Win32 quadmath] isfinite() does not accommodate __float128 HOT 11
- Sub::Identify not being detected as a prerequisite HOT 4
- Can't install `[email protected]` for `perl-5.10.1` on macOS 14 Sonoma HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datetime.pm.