Repository: denoland/std (TypeScript)

Issue:
Issue Parsing Positive Time Zone Offset (`+07:00`) in `@std/toml`
**Describe the bug**

Date strings like `1979-05-27T00:32:00+07:00` is not parsed.

According to the [TOML Spec](https://toml.io/en/v1.0.0#offset-date-time), [RFC 3339](https://tools.ietf.org/html/rfc3339) formatted date-time with offset should be parsed.

**Steps to Reproduce**

```js
import * as toml from "@std/toml";

toml.parse("time = 1979-05-27T00:32:00-07:00") // ok
toml.parse("time = 1979-05-27T00:32:00+07:00") // not ok
//                                    ^
```

Then

```
error: Uncaught (in promise) SyntaxError: Parse error on line 1, column 26: Unexpected character: "+"
      throw new SyntaxError(message);
            ^
    at https://jsr.io/@std/toml/1.0.1/_parser.ts:801:13
    at Module.parse (https://jsr.io/@std/toml/1.0.1/parse.ts:26:24)
    at index.ts:4:6
```

**Expected behavior**

Both negative and positive time zone offsets (`-07:00` and `+07:00`) should be parsed correctly.

**Environment**

<!-- please complete the following information -->

- OS: Ubuntu 20.04
- deno version: 1.43.6
- std version: `jsr:@std/toml@^1.0.1`



Discussion:

Patch:
diff --git a/toml/_parser.ts b/toml/_parser.ts
index a44497ecd0ab..1b351896f2ce 100644
--- a/toml/_parser.ts
+++ b/toml/_parser.ts
@@ -608,7 +608,7 @@ export function dateTime(scanner: Scanner): ParseResult<Date> {
 
   const acc = [];
   // example: 1979-05-27T00:32:00Z
-  while (/[ 0-9TZ.:-]/.test(scanner.char()) && !scanner.eof()) {
+  while (/[ 0-9TZ.:+-]/.test(scanner.char()) && !scanner.eof()) {
     acc.push(scanner.char());
     scanner.next();
   }


Test patch:
diff --git a/toml/parse_test.ts b/toml/parse_test.ts
index 0f0904f1f7bc..b851cbe2caaf 100644
--- a/toml/parse_test.ts
+++ b/toml/parse_test.ts
@@ -295,6 +295,10 @@ Deno.test({
       parse("1979-05-27T00:32:00-07:00"),
       new Date("1979-05-27T07:32:00Z"),
     );
+    assertEquals(
+      parse("1979-05-27T14:32:00+07:00"),
+      new Date("1979-05-27T07:32:00Z"),
+    );
     assertEquals(
       parse("1979-05-27T00:32:00.999999-07:00"),
       new Date("1979-05-27T07:32:00.999Z"),
@@ -785,8 +789,9 @@ Deno.test({
       datetime: {
         odt1: new Date("1979-05-27T07:32:00Z"),
         odt2: new Date("1979-05-27T00:32:00-07:00"),
-        odt3: new Date("1979-05-27T00:32:00.999999-07:00"),
-        odt4: new Date("1979-05-27 07:32:00Z"),
+        odt3: new Date("1979-05-27T14:32:00+07:00"),
+        odt4: new Date("1979-05-27T00:32:00.999999-07:00"),
+        odt5: new Date("1979-05-27 07:32:00Z"),
         ld1: new Date("1979-05-27"),
         lt1: "07:32:00",
         lt2: "00:32:00.999999",
diff --git a/toml/testdata/datetime.toml b/toml/testdata/datetime.toml
index 62377a4ba2e3..1bf92c2dc209 100644
--- a/toml/testdata/datetime.toml
+++ b/toml/testdata/datetime.toml
@@ -1,8 +1,9 @@
 [datetime]
 odt1 = 1979-05-27T07:32:00Z # Comment
 odt2 = 1979-05-27T00:32:00-07:00 # Comment
-odt3 = 1979-05-27T00:32:00.999999-07:00 # Comment
-odt4 = 1979-05-27 07:32:00Z # Comment
+odt3 = 1979-05-27T14:32:00+07:00 # Comment
+odt4 = 1979-05-27T00:32:00.999999-07:00 # Comment
+odt5 = 1979-05-27 07:32:00Z # Comment
 ld1 = 1979-05-27 # Comment
 lt1 = 07:32:00 # Comment
 lt2 = 00:32:00.999999 # Comment