Repository: briannesbitt/Carbon (PHP)

Issue:
`CarbonTimeZone` behaves differently from `DateTimeZone` for short, signed offset values
<!--
    🛑 DON'T REMOVE ME.
    This issue template apply to all
      - bug reports,
      - feature proposals,
      - and documentation requests

    Having all those informations will allow us to know exactly
    what you expect and answer you faster and precisely (answer
    that matches your Carbon version, PHP version and usage).
    
    Note: Comments between <!- - and - -> won't appear in the final
    issue (See [Preview] tab).
-->
Hello,

I encountered an issue with the following code:
```php
echo (new CarbonTimeZone('+01'))->getName()
```

Carbon version: 2.57.0
PHP version: 8.1.1

<!--
    Run the command `composer show nesbot/carbon`
    to get "versions"
    Use `echo phpversion();`
    to get PHP version.

    Some issues can depends on your context, settings,
    macros, timezone, language. So to be sure the code
    you give is enough to reproduce your bug, try it
    first in:
    https://try-carbon.herokuapp.com/?theme=xcode&export&embed

    You can use the [Options] button to change the version
    then when you get the bug with this editor, you can use
    the [Export] button, copy the link of the opened tab,
    then paste it in the issue. Then we can immediatly get
    your issue.
-->


I expected to get:

```
+01:00
```
<!--
    Always give your expectations. Each use has their owns.
    You may want daylight saving time to be taken into account,
    someone else want it to be ignored. You may want timezone
    to be used in comparisons, someone else may not, etc.
-->

But I actually get an exception:

```
DateTimeZone::__construct(): Unknown or bad timezone (++01:00)
```
<!--
    If you did not succeed to get the same result in
    https://try-carbon.herokuapp.com/ then precise the
    result you get.
-->

Doing the same with a native DateTimeZone works as expected:

```php
echo (new DateTimeZone('+01'))->getName()
```

shows:

```
+01:00
```

Thanks!



Discussion:
Hello 👋 

Thanks for the report.

I will check if we can and should support this.

In the meantime I recommend to use the explicit full timezone string:

```php
echo (new CarbonTimeZone('+01:00'))->getName();
```

It's supported, and the less ambiguous way IMO.
I'm all good, don't worry about that. Found out about this discrepancy when playing around with 8601, pretty much by accident. Just figured I'd make someone aware.

Cheers for all you do!



Patch:
diff --git a/src/Carbon/CarbonTimeZone.php b/src/Carbon/CarbonTimeZone.php
index b4d16ba97a..fdb31b98ed 100644
--- a/src/Carbon/CarbonTimeZone.php
+++ b/src/Carbon/CarbonTimeZone.php
@@ -30,7 +30,7 @@ protected static function parseNumericTimezone($timezone)
             throw new InvalidTimeZoneException('Absolute timezone offset cannot be greater than 100.');
         }
 
-        return ($timezone >= 0 ? '+' : '').$timezone.':00';
+        return ($timezone >= 0 ? '+' : '').ltrim($timezone, '+').':00';
     }
 
     protected static function getDateTimeZoneNameFromMixed($timezone)


Test patch:
diff --git a/tests/CarbonTimeZone/CreateTest.php b/tests/CarbonTimeZone/CreateTest.php
index 4bfced7181..8567606a7f 100644
--- a/tests/CarbonTimeZone/CreateTest.php
+++ b/tests/CarbonTimeZone/CreateTest.php
@@ -29,6 +29,22 @@ public function testCreate()
         $tz = CarbonTimeZone::create(6);
 
         $this->assertSame('+06:00', $tz->getName());
+
+        $tz = CarbonTimeZone::create('+01');
+
+        $this->assertSame('+01:00', $tz->getName());
+
+        $tz = new CarbonTimeZone('+01');
+
+        $this->assertSame('+01:00', $tz->getName());
+
+        $tz = CarbonTimeZone::create('-01');
+
+        $this->assertSame('-01:00', $tz->getName());
+
+        $tz = new CarbonTimeZone('-01');
+
+        $this->assertSame('-01:00', $tz->getName());
     }
 
     public function testInstance()