[Jifty-commit] r6942 - jifty/trunk/lib/Jifty

Jifty commits jifty-commit at lists.jifty.org
Tue May 5 17:32:07 EDT 2009


Author: sartak
Date: Tue May  5 17:32:07 2009
New Revision: 6942

Modified:
   jifty/trunk/lib/Jifty/DateTime.pm

Log:
Make Jifty::DateTime->from_epoch(100) dwim

Modified: jifty/trunk/lib/Jifty/DateTime.pm
==============================================================================
--- jifty/trunk/lib/Jifty/DateTime.pm	(original)
+++ jifty/trunk/lib/Jifty/DateTime.pm	Tue May  5 17:32:07 2009
@@ -139,12 +139,17 @@
 
 =head2 from_epoch ARGS
 
-See L<DateTime/from_epoch> and L<Jifty::DateTime/now>.
+See L<DateTime/from_epoch> and L<Jifty::DateTime/now>. This handles the common
+mistake of C<from_epoch($epoch)> as well.
 
 =cut
 
 sub from_epoch {
     my $class = shift;
+
+    # from_epoch(100) should dwim
+    unshift @_, 'epoch' if @_ == 1;
+
     my %args  = (
         current_user => undef,
         #time_zone => undef, # DateTime doesn't like undef time_zone


More information about the Jifty-commit mailing list