#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package Formats;
use strict;

use lib '/app/tools/common/lib';
use Common::RSMath;
use Common::Locale;
use Common::Client;

sub formatNumber {
    my ($value) = @_;

    $value = Common::Client::Current()->Locale()->formatNumber($value);

    return $value;
}

sub formatNumberSmall {  # Rounded to 2 decimal places
    my ($value) = @_;

    $value = sprintf( "%.2f", Common::RSMath::round( $value, 2 ) );
    $value = Common::Client::Current()->Locale()->formatNumber($value);

    return $value;
}

sub formatDate {
    my ($value) = @_;

    $value = Common::Client::Current()->Locale()->formatDate($value);

    return $value;
}

sub formatMoney {
    my ($value) = @_;

    # Use our own rounding algorithm.
    #
    my $rVal = Common::RSMath::round( $value, 2 );

    $rVal = Common::Client::Current()->Locale()->formatMoney($rVal);

    return $rVal;
}

sub formatPercent {
    my ($value) = @_;

    # Use our own rounding algorithm.
    #
    $value = Common::RSMath::round( $value, 2 );

    my $rVal = sprintf( '%.2f', $value );

    $rVal = Common::Client::Current()->Locale()->formatNumber($rVal) . '%';

    return $rVal;
}

1;
