mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-20 03:08:11 +00:00
Set upload size as "***MB" would give errors.
This commit is contained in:
@@ -34,6 +34,7 @@ use stdClass;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Steam.
|
* Class Steam.
|
||||||
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
class Steam
|
class Steam
|
||||||
@@ -228,11 +229,11 @@ class Steam
|
|||||||
$modified = null === $entry->modified ? '0' : (string)$entry->modified;
|
$modified = null === $entry->modified ? '0' : (string)$entry->modified;
|
||||||
$foreignModified = null === $entry->modified_foreign ? '0' : (string)$entry->modified_foreign;
|
$foreignModified = null === $entry->modified_foreign ? '0' : (string)$entry->modified_foreign;
|
||||||
$amount = '0';
|
$amount = '0';
|
||||||
if ($currencyId === (int) $entry->transaction_currency_id || 0 === $currencyId) {
|
if ($currencyId === (int)$entry->transaction_currency_id || 0 === $currencyId) {
|
||||||
// use normal amount:
|
// use normal amount:
|
||||||
$amount = $modified;
|
$amount = $modified;
|
||||||
}
|
}
|
||||||
if ($currencyId === (int) $entry->foreign_currency_id) {
|
if ($currencyId === (int)$entry->foreign_currency_id) {
|
||||||
// use foreign amount:
|
// use foreign amount:
|
||||||
$amount = $foreignModified;
|
$amount = $foreignModified;
|
||||||
}
|
}
|
||||||
@@ -488,7 +489,7 @@ class Steam
|
|||||||
->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) AS max_date')]);
|
->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) AS max_date')]);
|
||||||
|
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
$date = new Carbon($entry->max_date,'UTC');
|
$date = new Carbon($entry->max_date, 'UTC');
|
||||||
$date->setTimezone(config('app.timezone'));
|
$date->setTimezone(config('app.timezone'));
|
||||||
$list[(int)$entry->account_id] = $date;
|
$list[(int)$entry->account_id] = $date;
|
||||||
}
|
}
|
||||||
@@ -520,6 +521,7 @@ class Steam
|
|||||||
if (null === $amount) {
|
if (null === $amount) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bcmul($amount, '-1');
|
return bcmul($amount, '-1');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,25 +532,25 @@ class Steam
|
|||||||
*/
|
*/
|
||||||
public function phpBytes(string $string): int
|
public function phpBytes(string $string): int
|
||||||
{
|
{
|
||||||
$string = strtolower($string);
|
$string = str_replace(['kb', 'mb', 'gb'], ['k', 'm', 'g'], strtolower($string));
|
||||||
|
|
||||||
if (false !== stripos($string, 'k')) {
|
if (false !== stripos($string, 'k')) {
|
||||||
// has a K in it, remove the K and multiply by 1024.
|
// has a K in it, remove the K and multiply by 1024.
|
||||||
$bytes = bcmul(rtrim($string, 'kK'), '1024');
|
$bytes = bcmul(rtrim($string, 'k'), '1024');
|
||||||
|
|
||||||
return (int)$bytes;
|
return (int)$bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false !== stripos($string, 'm')) {
|
if (false !== stripos($string, 'm')) {
|
||||||
// has a M in it, remove the M and multiply by 1048576.
|
// has a M in it, remove the M and multiply by 1048576.
|
||||||
$bytes = bcmul(rtrim($string, 'mM'), '1048576');
|
$bytes = bcmul(rtrim($string, 'm'), '1048576');
|
||||||
|
|
||||||
return (int)$bytes;
|
return (int)$bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false !== stripos($string, 'g')) {
|
if (false !== stripos($string, 'g')) {
|
||||||
// has a G in it, remove the G and multiply by (1024)^3.
|
// has a G in it, remove the G and multiply by (1024)^3.
|
||||||
$bytes = bcmul(rtrim($string, 'gG'), '1073741824');
|
$bytes = bcmul(rtrim($string, 'g'), '1073741824');
|
||||||
|
|
||||||
return (int)$bytes;
|
return (int)$bytes;
|
||||||
}
|
}
|
||||||
@@ -606,7 +608,8 @@ class Steam
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getLocaleArray(string $locale): array {
|
public function getLocaleArray(string $locale): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
sprintf('%s.utf8', $locale),
|
sprintf('%s.utf8', $locale),
|
||||||
sprintf('%s.UTF-8', $locale),
|
sprintf('%s.UTF-8', $locale),
|
||||||
|
Reference in New Issue
Block a user