mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-05 18:23:48 +00:00
resolved timezones
This commit is contained in:
@@ -667,7 +667,7 @@ return [
|
||||
'app_description' => 'Your self-hosted storage cloud software powered by Laravel and Vue',
|
||||
'user_not_fount' => 'We can\'t find a user with that e-mail address.',
|
||||
'incorrect_password' => 'Sorry, your password is incorrect.',
|
||||
'time' => '%d. %B. %Y at %H:%M',
|
||||
'time' => 'd. M. Y, h:i',
|
||||
'home' => 'Home',
|
||||
'shared_link_email_subject' => '🙋 :user share some files with you. Look at it!',
|
||||
'shared_link_email_greeting' => 'Hello!',
|
||||
|
||||
@@ -37,8 +37,8 @@ class UserResource extends JsonResource
|
||||
'two_factor_authentication' => $this->two_factor_secret ? true : false,
|
||||
'socialite_account' => $this->password ? false : true,
|
||||
'storage' => $this->storage,
|
||||
'created_at' => format_date($this->created_at, '%d. %b. %Y'),
|
||||
'updated_at' => format_date($this->updated_at, '%d. %B. %Y'),
|
||||
'created_at' => format_date($this->created_at, 'd. M. Y'),
|
||||
'updated_at' => format_date($this->updated_at, 'd. M. Y'),
|
||||
],
|
||||
'relationships' => [
|
||||
'settings' => new SettingsResource($this->settings),
|
||||
|
||||
@@ -133,13 +133,13 @@ class UserStorageResource extends JsonResource
|
||||
->get();
|
||||
|
||||
$upload = $trafficRecords->map(fn ($record) => [
|
||||
'created_at' => format_date($record->created_at, '%d. %B'),
|
||||
'created_at' => format_date($record->created_at, 'd. M. '),
|
||||
'percentage' => $uploadMax !== 0 ? round(($record->upload / $uploadMax) * 100, 2) : 0,
|
||||
'amount' => Metric::bytes($record->upload)->format(),
|
||||
]);
|
||||
|
||||
$download = $trafficRecords->map(fn ($record) => [
|
||||
'created_at' => format_date($record->created_at, '%d. %B'),
|
||||
'created_at' => format_date($record->created_at, 'd. M. '),
|
||||
'percentage' => $downloadMax !== 0 ? round(($record->download / $downloadMax) * 100, 2) : 0,
|
||||
'amount' => Metric::bytes($record->download)->format(),
|
||||
]);
|
||||
|
||||
@@ -32,9 +32,9 @@ class UserSubscription extends JsonResource
|
||||
'capacity' => (int) $subscription['product']['metadata']['capacity'],
|
||||
'capacity_formatted' => format_gigabytes($subscription['product']['metadata']['capacity']),
|
||||
'slug' => $subscription['plan']['id'],
|
||||
'canceled_at' => format_date($active_subscription['canceled_at'], '%d. %B. %Y'),
|
||||
'created_at' => format_date($active_subscription['current_period_start'], '%d. %B. %Y'),
|
||||
'ends_at' => format_date($active_subscription['current_period_end'], '%d. %B. %Y'),
|
||||
'canceled_at' => format_date($active_subscription['canceled_at'], 'd. M. Y'),
|
||||
'created_at' => format_date($active_subscription['current_period_start'], 'd. M. Y'),
|
||||
'ends_at' => format_date($active_subscription['current_period_end'], 'd. M. Y'),
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -66,13 +66,13 @@ class GetDashboardDataController extends Controller
|
||||
->get();
|
||||
|
||||
$upload = $trafficRecords->map(fn ($record) => [
|
||||
'created_at' => format_date($record->created_at, '%d. %B'),
|
||||
'created_at' => format_date($record->created_at, 'd. M. '),
|
||||
'percentage' => intval($trafficRecords->max('upload')) !== 0 ? round(($record->upload / $trafficRecords->max('upload')) * 100, 2) : 0,
|
||||
'amount' => Metric::bytes($record->upload)->format(),
|
||||
]);
|
||||
|
||||
$download = $trafficRecords->map(fn ($record) => [
|
||||
'created_at' => format_date($record->created_at, '%d. %B'),
|
||||
'created_at' => format_date($record->created_at, 'd. M. '),
|
||||
'percentage' => intval($trafficRecords->max('download')) !== 0 ? round(($record->download / $trafficRecords->max('download')) * 100, 2) : 0,
|
||||
'amount' => Metric::bytes($record->download)->format(),
|
||||
]);
|
||||
|
||||
@@ -33,15 +33,11 @@ class FileResource extends JsonResource
|
||||
'thumbnail' => $this->thumbnail,
|
||||
'metadata' => $this->metadata,
|
||||
'parent_id' => $this->parent_id,
|
||||
'updated_at' => $this->updated_at,
|
||||
'created_at' => Carbon::parse($this->created_at)->diffForHumans(),
|
||||
'deleted_at' => $this->deleted_at ? Carbon::parse($this->deleted_at)->diffForHumans() : null,
|
||||
/*'updated_at' => format_date(
|
||||
set_time_by_user_timezone($this->updated_at), __t('time')
|
||||
),
|
||||
'created_at' => format_date(
|
||||
set_time_by_user_timezone($this->created_at), __t('time')
|
||||
),*/
|
||||
'created_at' => set_time_by_user_timezone($this->owner, $this->created_at),
|
||||
'updated_at' => set_time_by_user_timezone($this->owner, $this->updated_at),
|
||||
'deleted_at' => $this->deleted_at
|
||||
? set_time_by_user_timezone($this->owner, $this->deleted_at)
|
||||
: null,
|
||||
],
|
||||
'relationships' => [
|
||||
$this->mergeWhen($this->shared, fn () => [
|
||||
|
||||
@@ -24,15 +24,11 @@ class FolderResource extends JsonResource
|
||||
'isTeamFolder' => $this->team_folder,
|
||||
'items' => $this->items,
|
||||
'trashed_items' => $this->trashed_items,
|
||||
'updated_at' => $this->updated_at,
|
||||
'created_at' => Carbon::parse($this->created_at)->diffForHumans(),
|
||||
'deleted_at' => $this->deleted_at ? Carbon::parse($this->deleted_at)->diffForHumans() : null,
|
||||
/*'updated_at' => format_date(
|
||||
set_time_by_user_timezone($this->updated_at), __t('time')
|
||||
),
|
||||
'created_at' => format_date(
|
||||
set_time_by_user_timezone($this->created_at), __t('time')
|
||||
),*/
|
||||
'created_at' => set_time_by_user_timezone($this->owner, $this->created_at),
|
||||
'updated_at' => set_time_by_user_timezone($this->owner, $this->updated_at),
|
||||
'deleted_at' => $this->deleted_at
|
||||
? set_time_by_user_timezone($this->owner, $this->deleted_at)
|
||||
: null,
|
||||
],
|
||||
'relationships' => [
|
||||
$this->mergeWhen($this->teamMembers, fn () => [
|
||||
|
||||
@@ -30,7 +30,7 @@ class TransactionResource extends JsonResource
|
||||
'metadata' => $this->metadata
|
||||
? resolve(FormatUsageEstimatesAction::class)($this->currency, $this->metadata)
|
||||
: null,
|
||||
'created_at' => $this->created_at->formatLocalized('%d. %b. %Y'),
|
||||
'created_at' => $this->created_at->formatLocalized('d. M. Y'),
|
||||
'updated_at' => $this->updated_at,
|
||||
],
|
||||
'relationships' => [
|
||||
|
||||
@@ -580,16 +580,12 @@ if (! function_exists('filter_folders_ids')) {
|
||||
if (! function_exists('format_date')) {
|
||||
/**
|
||||
* Format localized date
|
||||
*
|
||||
* @param $date
|
||||
* @param string $format
|
||||
* @return string
|
||||
*/
|
||||
function format_date($date, $format = '%d. %B. %Y, %H:%M')
|
||||
function format_date($date, string $format = 'd. M. Y, h:i'): string
|
||||
{
|
||||
$start = Carbon::parse($date);
|
||||
|
||||
return $start->formatLocalized($format);
|
||||
return $start->translatedFormat($format);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -949,17 +945,13 @@ if (! function_exists('set_time_by_user_timezone')) {
|
||||
/**
|
||||
* Set time by user timezone GMT
|
||||
*/
|
||||
function set_time_by_user_timezone(string $time): string | Carbon
|
||||
function set_time_by_user_timezone($user, $createdAt): string | Carbon
|
||||
{
|
||||
$user = Auth::user();
|
||||
$timezone = $user->settings->timezone ?? 0;
|
||||
|
||||
if ($user) {
|
||||
$time_zone = $user->settings->timezone ?? 0;
|
||||
|
||||
return Carbon::parse($time)->addMinutes($time_zone * 60);
|
||||
}
|
||||
|
||||
return $time;
|
||||
return Carbon::parse($createdAt)
|
||||
->addMinutes($timezone * 60)
|
||||
->translatedFormat('d. M. Y, h:i');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,28 +35,27 @@ class UserAccountTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* todo: finish test
|
||||
* @test
|
||||
*/
|
||||
public function it_test_user_timezone()
|
||||
{
|
||||
$user = User::factory()
|
||||
->create(['role' => 'user']);
|
||||
->hasSettings([
|
||||
'timezone' => '2.0',
|
||||
])
|
||||
->create();
|
||||
|
||||
Folder::factory(Folder::class)
|
||||
Folder::factory()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
$user->settings()->update([
|
||||
'timezone' => '2.0',
|
||||
]);
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->getJson('/api/browse/folders/undefined')
|
||||
->assertJsonFragment([
|
||||
'created_at' => '01. January. 2021 at 02:00',
|
||||
'created_at' => '01. Jan. 2021, 02:00',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -167,8 +166,8 @@ class UserAccountTest extends TestCase
|
||||
'capacity' => '1',
|
||||
'capacity_formatted' => '1GB',
|
||||
],
|
||||
'created_at' => format_date($user->created_at, '%d. %b. %Y'),
|
||||
'updated_at' => format_date($user->updated_at, '%d. %B. %Y'),
|
||||
'created_at' => format_date($user->created_at, 'd. M. Y'),
|
||||
'updated_at' => format_date($user->updated_at, 'd. M. Y'),
|
||||
],
|
||||
'meta' => [
|
||||
'restrictions' => [
|
||||
|
||||
Reference in New Issue
Block a user