[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[3856] trunk/LedgerSMB/PGDate.pm



Revision: 3856
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3856&view=rev
Author:   einhverfr
Date:     2011-10-13 20:07:59 +0000 (Thu, 13 Oct 2011)
Log Message:
-----------
Minor corrections to PGDate.pm

Modified Paths:
--------------
    trunk/LedgerSMB/PGDate.pm

Modified: trunk/LedgerSMB/PGDate.pm
===================================================================
--- trunk/LedgerSMB/PGDate.pm	2011-10-13 15:40:26 UTC (rev 3855)
+++ trunk/LedgerSMB/PGDate.pm	2011-10-13 20:07:59 UTC (rev 3856)
@@ -19,7 +19,7 @@
 
 =cut
 
-has format => (isa => 'Str', is => 'ro', required => '1');
+has format => (isa => 'Str', is => 'rw', required => '1');
 
 =item date
 A DateTime object for internal storage and processing.
@@ -200,7 +200,7 @@
     my $class = shift;
     my %args  = (ref($_[0]) eq 'HASH')? %{$_[0]}: @_;
     if ($args{string}){
-        return $formats->{$args{format}}->from_string(
+        return $formats->{$args{format}}->{from_string}(
                                                    $args{string}, $args{format}
         );
     } else {
@@ -212,13 +212,14 @@
 
 =over
 
-=item to_string
+=item to_string(optional $format)
 This returns the human readable formatted date.
 
 =cut
 
 sub to_string {
-    my ($self) = @_;
+    my ($self, $format) = @_;
+    $format ||= $self->format;
     my $sep;
     if ($self->format =~ /[^YMD]/){
         $self->format =~ /MM(.)/;
@@ -226,7 +227,7 @@
     } else {
         $sep = '';
     }
-    $formats->{"$self->format"}->to_string($self, $sep);
+    $formats->{$format}->{to_string}($self, $sep);
 }
 
 =item to_dbstring
@@ -236,7 +237,7 @@
 
 sub to_dbstring {
     my ($self) = @_;
-    $formats->{"YYYY-MM-DD"}->to_string($self, '-');
+    $formats->{"YYYY-MM-DD"}->{to_string}($self, '-');
 }
 
 1;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.