Commit e3cd521b authored by Frank Bergmann's avatar Frank Bergmann

- Reorganized /invoice/view

- Added "Create XXX from YYY"
parent 4254b4f2
...@@ -1228,3 +1228,51 @@ ad_proc bd_formatDateTz { date fmt gmt localTz} { ...@@ -1228,3 +1228,51 @@ ad_proc bd_formatDateTz { date fmt gmt localTz} {
return $r return $r
} }
# ---------------------------------------------------------------
# Auxilary functions
# ---------------------------------------------------------------
ad_proc im_date_format_locale { cur {min_decimals ""} {max_decimals ""} } {
Takes a number in "Amercian" format (decimals separated by ".") and
returns a string formatted according to the current locale.
} {
ns_log Notice "im_date_format_locale($cur, $min_decimals, $max_decimals)"
# Remove thousands separating comas eventually
regsub "\," $cur "" cur
# Check if the number has no decimals (for ocurrence of ".")
if {![regexp {\.} $cur]} {
# No decimals - set digits to ""
set digits $cur
set decimals ""
} else {
# Split the digits from the decimals
regexp {([^\.]*)\.(.*)} $cur match digits decimals
}
if {![string equal "" $min_decimals]} {
# Pad decimals with trailing "0" until they reach $num_decimals
while {[string length $decimals] < $min_decimals} {
append decimals "0"
}
}
if {![string equal "" $max_decimals]} {
# Adjust decimals by cutting off digits if too long:
if {[string length $decimals] > $max_decimals} {
set decimals [string range $decimals 0 [expr $max_decimals-1]]
}
}
# Format the digits
if {[string equal "" $digits]} {
set digits "0"
}
return "$digits.$decimals"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment