Skip to content

Commit

Permalink
docs: Add warning block
Browse files Browse the repository at this point in the history
  • Loading branch information
sorairolake committed Feb 24, 2025
1 parent 87b120e commit 17c4cda
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ number of 100-nanosecond intervals that have elapsed since "1601-01-01 00:00:00
UTC", and is used as timestamps such as [NTFS] and [7z]. Windows uses a file
time to record when an application creates, accesses, or writes to a file.

Note that many environments, such as the [Win32 API], may limit the largest
value of the file time to "+30828-09-14 02:48:05.477580700 UTC", which is equal
to the largest value of a 64-bit signed integer type when represented as an
underlying integer value. This is the largest file time accepted by the
[`FileTimeToSystemTime`] function of the Win32 API.
> [!IMPORTANT]
> Note that many environments, such as the [Win32 API], may limit the largest
> value of the file time to "+30828-09-14 02:48:05.477580700 UTC", which is
> equal to the largest value of a 64-bit signed integer type when represented
> as an underlying integer value. This is the largest file time accepted by the
> [`FileTimeToSystemTime`] function of the Win32 API.
## Usage

Expand Down
16 changes: 16 additions & 0 deletions src/file_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ const FILE_TIMES_PER_SEC: u64 = 10_000_000;
/// This represents the same value as the [`FILETIME`] structure of the [Win32
/// API], which represents a 64-bit unsigned integer value.
///
/// <div class="warning">
///
/// Note that many environments, such as the Win32 API, may limit the largest
/// value of the file time to "+30828-09-14 02:48:05.477580700 UTC", which is
/// equal to [`i64::MAX`], the largest value of a 64-bit signed integer type
/// when represented as an underlying integer value. This is the largest file
/// time accepted by the [`FileTimeToSystemTime`] function of the Win32 API.
///
/// </div>
///
/// Also, the file time is sometimes represented as an [`i64`] value, such as in
/// the [`DateTime.FromFileTimeUtc`] method and the [`DateTime.ToFileTimeUtc`]
/// method in [.NET].
Expand Down Expand Up @@ -175,10 +179,14 @@ impl FileTime {
/// Returns the memory representation of this `FileTime` as a byte array in
/// native byte order.
///
/// <div class="warning">
///
/// As the target platform's native endianness is used, portable code should
/// use [`FileTime::to_be_bytes`] or [`FileTime::to_le_bytes`], as
/// appropriate, instead.
///
/// </div>
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -268,10 +276,14 @@ impl FileTime {
/// Creates a native endian `FileTime` value from its memory representation
/// as a byte array in native endianness.
///
/// <div class="warning">
///
/// As the target platform's native endianness is used, portable code likely
/// wants to use [`FileTime::from_be_bytes`] or [`FileTime::from_le_bytes`],
/// as appropriate instead.
///
/// </div>
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -409,10 +421,14 @@ impl FromStr for FileTime {

/// Parses a string `s` to return a value of `FileTime`.
///
/// <div class="warning">
///
/// The string is expected to be a decimal non-negative integer. If the
/// string is not a decimal integer, use [`u64::from_str_radix`] and
/// [`FileTime::new`] instead.
///
/// </div>
///
/// # Errors
///
/// Returns [`Err`] if [`u64::from_str`] returns an error.
Expand Down
4 changes: 4 additions & 0 deletions src/file_time/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ impl FileTime {
/// environments, it is generally recommended that you use this constant as
/// the largest value instead of [`FileTime::MAX`].
///
/// <div class="warning">
///
/// Note that the actual largest value of the [`SYSTEMTIME`] structure of
/// the Win32 API is "+30827-12-31 23:59:59.999000000" (which is either in
/// UTC or local time, depending on the function that is being called),
/// which is different from this constant. The `FileTimeToSystemTime`
/// function accepts the value of this constant, but it is an invalid date
/// and time for the `SYSTEMTIME` structure.
///
/// </div>
///
/// # Examples
///
/// ```
Expand Down
8 changes: 8 additions & 0 deletions src/file_time/dos_date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ impl FileTime {
/// a multiple of 15 minute intervals, returns the UTC date and time as a
/// date and time and [`None`] as the UTC offset.
///
/// <div class="warning">
///
/// Note that exFAT supports `resolution` for creation and last modified
/// times, and the `offset` return value for these times and last access
/// time, but other file systems and file formats may not support these. For
/// example, the built-in timestamp of ZIP used for last modified time only
/// records `date` and `time`, not `resolution` and the `offset` return
/// value.
///
/// </div>
///
/// # Errors
///
/// Returns [`Err`] if the resulting date and time is out of range for
Expand Down Expand Up @@ -170,12 +174,16 @@ impl FileTime {
/// [`None`] or is not a multiple of 15 minute intervals, assumes the
/// provided date and time is in UTC.
///
/// <div class="warning">
///
/// Note that exFAT supports `resolution` for creation and last modified
/// times, and `offset` for these times and last access time, but other file
/// systems and file formats may not support these. For example, the
/// built-in timestamp of ZIP used for last modified time only records
/// `date` and `time`, not `resolution` and `offset`.
///
/// </div>
///
/// # Errors
///
/// Returns [`Err`] if `date` or `time` is an invalid date and time.
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@
//! timestamps such as [NTFS] and [7z]. Windows uses a file time to record when
//! an application creates, accesses, or writes to a file.
//!
//! <div class="warning">
//!
//! Note that many environments, such as the [Win32 API], may limit the largest
//! value of the file time to "+30828-09-14 02:48:05.477580700 UTC", which is
//! equal to [`i64::MAX`], the largest value of a 64-bit signed integer type
//! when represented as an underlying integer value. This is the largest file
//! time accepted by the [`FileTimeToSystemTime`] function of the Win32 API.
//!
//! </div>
//!
//! # Examples
//!
//! ## Basic usage
Expand Down
4 changes: 4 additions & 0 deletions src/serde_with/iso_8601.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
//!
//! Use this module in combination with Serde's [`with`] attribute.
//!
//! <div class="warning">
//!
//! If the `large-dates` feature is not enabled, the largest date and time is
//! "9999-12-31 23:59:59.999999999 UTC".
//!
//! </div>
//!
//! # Examples
//!
//! ```
Expand Down
4 changes: 4 additions & 0 deletions src/serde_with/iso_8601/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
//!
//! Use this module in combination with Serde's [`with`] attribute.
//!
//! <div class="warning">
//!
//! If the `large-dates` feature is not enabled, the largest date and time is
//! "9999-12-31 23:59:59.999999999 UTC".
//!
//! </div>
//!
//! # Examples
//!
//! ```
Expand Down

0 comments on commit 17c4cda

Please sign in to comment.