rust/library/std/src
Matthias Krüger fb98f7adc3
Rollup merge of #109660 - ijackson:leap, r=thomcc
Document that SystemTime does not count leap seconds

Fixes #77994

This may not be entirely uncontroversial.  I know that `@Ekleog` is going to disagree.  However, in support of this docs change:

 This documents the current behaviour.  The alternative would be to plan to *change* the behaviour.

There are many programs which need to get a POSIX time (a `time_t`).  Right now, `duration_since(UNIX_EPOCH)` is the only facility in std that does that.  So, that is what programs use.  Changing the behaviour would  break[1] all of those programs.  We would need to define a new API that can be used to get a POSIX time, and get everyone to use it.  This seems highly unpalatable.

And, even if we wanted to do that, time with leap seconds is a lot less easy to work with.  We would need to arrange to have a leap seconds table available to `std` somehow, and make sure that it was kept up to date.  Currently we don't offer to do that for timezone data, which has similar needs.  There are other complications.  So it seems it would be awkwarrd to *implement* a facility that provides time including leap seconds, and the resulting value would be hard for applications to work with.

Therefore, I think it's clear that we don't want to plan to ever change `SystemTime`.  We should plan to keep it the way it is.  Providing TAI (for example) should be left to external crates, or additional APIs we may add in the future.

For more discussion see #77994 and in particular `@fanf2's` https://github.com/rust-lang/rust/issues/77994#issuecomment-1409448174

[1]  Of course, by "break" we really only mean *future* breakage in the case where there is, in fact, ever another leap second.  There may well not be: they are in the process of being abolished (although this is of course being contested).  But if we decide that `SystemTime::now().duraton_since(UNIX_EPOCH)` counts leap seconds, it would start to return `Durations`s that are 27s different to the current answers.   That's clearly unacceptable.  And we can hardly change `UNIX_EPOCH` by 27s.
2023-08-28 08:13:56 +02:00
..
backtrace Implement UnwindSafe and RefUnwindSafe for Backtrace 2023-07-31 10:38:24 +02:00
collections Increase clarity about Hash - Eq consistency in HashMap and HashSet docs 2023-08-07 20:31:49 -06:00
env Better Debug for Vars and VarsOs 2023-08-07 12:18:27 -04:00
error core/any: remove Provider trait 2023-08-13 13:07:53 -06:00
f32 Add gamma and ln_gamma functions to f32 and f64 2023-07-31 07:41:50 -07:00
f64 Add gamma and ln_gamma functions to f32 and f64 2023-07-31 07:41:50 -07:00
ffi Replace version placeholders with 1.73.0 2023-08-22 06:57:00 -04:00
fs Auto merge of #102757 - pcc:android-std-tests, r=workingjubilee 2023-07-26 07:57:32 +00:00
io Add a new helper to avoid calling io::Error::kind 2023-08-25 21:26:06 -04:00
net inline trivial (noop) flush calls 2023-07-28 18:09:12 -07:00
num rustc_expand: Mark inner #![test] attributes as soft-unstable 2020-11-20 19:35:03 +03:00
os Replace version placeholders with 1.73.0 2023-08-22 06:57:00 -04:00
panic review: fix nits and move panic safety tests to the correct place 2020-09-25 23:10:24 +02:00
path std: add tests for Path::with_extension 2023-07-14 13:19:45 -03:00
prelude correct std::prelude comment 2023-04-27 15:56:57 +02:00
process Workaround for old android not having echo 2023-07-05 09:54:16 +01:00
sync Update Sender documentation for Sync 2023-08-12 09:20:56 +05:30
sys wasi: round up the size for aligned_alloc 2023-08-26 11:50:16 -07:00
sys_common Auto merge of #114591 - joboet:thread_parking_ordering_fix, r=thomcc 2023-08-18 19:03:38 +00:00
thread Replace version placeholders with 1.73.0 2023-08-22 06:57:00 -04:00
time Rollup merge of #103056 - beetrees:timespec-bug-fix, r=thomcc 2023-05-05 18:40:32 +05:30
alloc.rs Correct and expand documentation of handle_alloc_error and set_alloc_error_hook. 2023-08-19 13:27:03 -07:00
ascii.rs Add the basic ascii::Char type 2023-05-03 22:09:33 -07:00
backtrace.rs Implement UnwindSafe and RefUnwindSafe for Backtrace 2023-07-31 10:38:24 +02:00
env.rs add a csky-unknown-linux-gnuabiv2 target 2023-08-14 23:02:36 +08:00
error.rs Expose core::error::request_value in std 2023-08-18 13:06:53 -04:00
f32.rs Rollup merge of #114754 - workingjubilee:gamma-ray-logger, r=thomcc 2023-08-25 09:00:12 +02:00
f64.rs Rollup merge of #114754 - workingjubilee:gamma-ray-logger, r=thomcc 2023-08-25 09:00:12 +02:00
fs.rs Add a new helper to avoid calling io::Error::kind 2023-08-25 21:26:06 -04:00
keyword_docs.rs docs: Add example, reference link for type keyword. 2023-08-21 20:00:43 +07:00
lib.rs Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00
macros.rs Fix typo in eprintln docs 2023-06-21 01:08:10 +01:00
num.rs Add Saturating type (based on Wrapping type) 2021-08-10 19:27:01 +02:00
panic.rs Shorten lifetime of even more panic temporaries 2023-05-15 03:47:37 -07:00
panicking.rs Change default panic handler message format. 2023-07-29 11:42:50 +02:00
path.rs actually this doesn't even affect doctests. nice. 2023-08-14 22:55:29 +02:00
primitive_docs.rs resolve conflicts 2023-08-18 15:22:58 +08:00
process.rs Replace version placeholders with 1.73.0 2023-08-22 06:57:00 -04:00
rt.rs Replace libstd, libcore, liballoc in line comments. 2022-12-30 14:00:42 +01:00
time.rs Rollup merge of #109660 - ijackson:leap, r=thomcc 2023-08-28 08:13:56 +02:00