Andrew Wallo 2 月之前
父節點
當前提交
a8e0046728
共有 1 個檔案被更改,包括 9 行新增1 行删除
  1. 9
    1
      app/Providers/MacroServiceProvider.php

+ 9
- 1
app/Providers/MacroServiceProvider.php 查看文件

@@ -488,12 +488,20 @@ class MacroServiceProvider extends ServiceProvider
488 488
             return $this->format($dateFormat);
489 489
         });
490 490
 
491
-        Carbon::macro('inCompanyTimezone', function () {
491
+        Carbon::macro('toCompanyTimezone', function () {
492 492
             $timezone = CompanySettingsService::getDefaultTimezone();
493 493
 
494
+            // This will convert the date to the company's timezone, possibly changing the date and time
494 495
             return $this->setTimezone($timezone);
495 496
         });
496 497
 
498
+        Carbon::macro('asCompanyTimezone', function () {
499
+            $timezone = CompanySettingsService::getDefaultTimezone();
500
+
501
+            // This will only change the timezone without converting the date and time
502
+            return $this->shiftTimezone($timezone);
503
+        });
504
+
497 505
         ExportColumn::macro('money', function () {
498 506
             $this->formatStateUsing(static function ($state) {
499 507
                 if (blank($state) || ! is_int($state)) {

Loading…
取消
儲存