Repository: duckdb/duckdb
File: src/include/duckdb/common/types/timestamp.hpp (C++)

Code before:
		return timestamp_t(-NumericLimits<int64_t>::Maximum());
	}                                             // NOLINT
	static constexpr inline timestamp_t epoch() { // NOLINT
		return timestamp_t(0);
	} // NOLINT
};

struct timestamp_tz_t : public timestamp_t { // NOLINT
	static constexpr timestamp_t infinity() {
		return timestamp_t::infinity();
	}
	static constexpr timestamp_t ninfinity() {
		return timestamp_t::ninfinity();
	}
};
struct timestamp_ns_t : public timestamp_t { // NOLINT
	static constexpr timestamp_t infinity() {
		return timestamp_t::infinity();
	}
	static constexpr timestamp_t ninfinity() {
		return timestamp_t::ninfinity();
	}
};
struct timestamp_ms_t : public timestamp_t { // NOLINT
	static constexpr timestamp_t infinity() {
		return timestamp_t(int64_t(NumericLimits<int64_t>::Maximum() / 1000) * 1000);
	}
	static constexpr timestamp_t ninfinity() {
		return timestamp_t(int64_t(-NumericLimits<int64_t>::Maximum() / 1000) * 1000);
	}
};
struct timestamp_sec_t : public timestamp_t { // NOLINT
	static constexpr timestamp_t infinity() {
		return timestamp_t(int64_t(NumericLimits<int64_t>::Maximum() / 1000000) * 1000000);
	}
	static constexpr timestamp_t ninfinity() {
		return timestamp_t(int64_t(-NumericLimits<int64_t>::Maximum() / 1000000) * 1000000);
	}
};

enum class TimestampCastResult : uint8_t { SUCCESS, ERROR_INCORRECT_FORMAT, ERROR_NON_UTC_TIMEZONE };

//! The Timestamp class is a static class that holds helper functions for the Timestamp
//! type.
class Timestamp {
public:
	// min timestamp is 290308-12-22 (BC)
	constexpr static const int32_t MIN_YEAR = -290308;
	constexpr static const int32_t MIN_MONTH = 12;
	constexpr static const int32_t MIN_DAY = 22;


Review comment (suggestion):
Let's always use `timestamp_t::infinity`.

@hawkfish could you perhaps have a look at this, it looks like there is an issue when casting infinity to non-microsecond timestamp types, e.g.:

```sql
D select 'infinity'::timestamp_ms as ts;
┌───────────────────────────┐
│            ts             │
│       timestamp_ms        │
├───────────────────────────┤
│ 294247-01-10 04:00:54.775 │
└───────────────────────────┘
```

Code after:
		return timestamp_t(-NumericLimits<int64_t>::Maximum());
	}                                             // NOLINT
	static constexpr inline timestamp_t epoch() { // NOLINT
		return timestamp_t(0);
	} // NOLINT
};

struct timestamp_tz_t : public timestamp_t { // NOLINT
};
struct timestamp_ns_t : public timestamp_t { // NOLINT
};
struct timestamp_ms_t : public timestamp_t { // NOLINT
};
struct timestamp_sec_t : public timestamp_t { // NOLINT
};

enum class TimestampCastResult : uint8_t { SUCCESS, ERROR_INCORRECT_FORMAT, ERROR_NON_UTC_TIMEZONE };

//! The Timestamp class is a static class that holds helper functions for the Timestamp
//! type.
class Timestamp {
public:
	// min timestamp is 290308-12-22 (BC)
	constexpr static const int32_t MIN_YEAR = -290308;
	constexpr static const int32_t MIN_MONTH = 12;
	constexpr static const int32_t MIN_DAY = 22;

public:
	//! Convert a string in the format "YYYY-MM-DD hh:mm:ss[.f][-+TH[:tm]]" to a timestamp object
	DUCKDB_API static timestamp_t FromString(const string &str);
	//! Convert a string where the offset can also be a time zone string: / [A_Za-z0-9/_]+/
	//! If has_offset is true, then the result is an instant that was offset from UTC
	//! If the tz is not empty, the result is still an instant, but the parts can be extracted and applied to the TZ
	DUCKDB_API static bool TryConvertTimestampTZ(const char *str, idx_t len, timestamp_t &result, bool &has_offset,
	                                             string_t &tz);
	DUCKDB_API static TimestampCastResult TryConvertTimestamp(const char *str, idx_t len, timestamp_t &result);
	DUCKDB_API static timestamp_t FromCString(const char *str, idx_t len);
	//! Convert a date object to a string in the format "YYYY-MM-DD hh:mm:ss"
	DUCKDB_API static string ToString(timestamp_t timestamp);

	DUCKDB_API static date_t GetDate(timestamp_t timestamp);

	DUCKDB_API static dtime_t GetTime(timestamp_t timestamp);
	//! Create a Timestamp object from a specified (date, time) combination
	DUCKDB_API static timestamp_t FromDatetime(date_t date, dtime_t time);
	DUCKDB_API static bool TryFromDatetime(date_t date, dtime_t time, timestamp_t &result);

	//! Is the character a valid part of a time zone name?
	static inline bool CharacterIsTimeZone(char c) {
		return StringUtil::CharacterIsAlpha(c) || StringUtil::CharacterIsDigit(c) || c == '_' || c == '/' || c == '+' ||
		       c == '-';