im
Clone
https://git.tahinli.com/Tahinli/im.git
0 watching0 forksRustAGPL-3.0542.8 KiBb9f0726Tahinli27 days ago34 commits
| 1 | //! UTC timestamps as stored in the database. |
| 2 | //! |
| 3 | //! The format is RFC 3339 with 9 fractional digits and a `Z` suffix. It has a fixed width, so |
| 4 | //! comparing two stamps as text gives the same order as comparing the times. |
| 5 | |
| 6 | use Duration; |
| 7 | |
| 8 | use |
| 9 | |
| 10 | ; |
| 11 | |
| 12 | const FORMAT: & = |
| 13 | format_description!; |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | /// Converts a `std` duration to the signed form `time` uses, saturating on overflow. |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | /// The current time as a stamp. |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | /// The stamp for `now + after`. Saturates at the maximum representable time instead of panicking. |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | /// The stamp for `now - before`. Saturates at the minimum representable time instead of panicking. |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | /// Parses a stored stamp back into a time. `None` for anything that is not a stamp. |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | /// The Unix time, in whole seconds, of a stored stamp. `None` when it is not a stamp. |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | /// The stamp `after` later than `stamp`, saturating at the largest time. `None` when `stamp` is not a |
| 51 | /// stamp. |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | /// The stamp `before` earlier than `stamp`, saturating at the smallest time. `None` when `stamp` is not |
| 59 | /// a stamp. |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | /// The current Unix time in whole seconds. |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | /// The stamp of a Unix time in whole seconds. `None` when the time is out of range. |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | /// The IANA time zone names of the database compiled into this build, sorted. The bundled database |
| 79 | /// is used on purpose, so every install offers the same list whatever the host has installed. |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | /// True only for an exact IANA name from [`zone_names`]. Matching is case-sensitive and nothing is |
| 90 | /// trimmed, so the stored value is always the canonical name. |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 |