| 732 | } |
| 733 | |
| 734 | func TestTimeConstantString(t *testing.T) { |
| 735 | // Unix epoch |
| 736 | epoch := Time(0) |
| 737 | str := epoch.String() |
| 738 | wantEpoch := `fn:time:parse_rfc3339("1970-01-01T00:00:00Z")` |
| 739 | if str != wantEpoch { |
| 740 | t.Errorf("Time(0).String() = %q, want %q", str, wantEpoch) |
| 741 | } |
| 742 | |
| 743 | // Time with nanoseconds: 2024-01-15T10:30:00.123456789Z |
| 744 | nanos := int64(1705314600123456789) |
| 745 | ts := Time(nanos) |
| 746 | str = ts.String() |
| 747 | expected := `fn:time:parse_rfc3339("2024-01-15T10:30:00.123456789Z")` |
| 748 | if str != expected { |
| 749 | t.Errorf("Time(%d).String() = %q, want %q", nanos, str, expected) |
| 750 | } |
| 751 | } |
| 752 | |
| 753 | func TestTimeValueError(t *testing.T) { |
| 754 | // TimeValue should fail on non-time constants |