actori_http/header/common/date.rs
1use crate::header::{HttpDate, DATE};
2use std::time::SystemTime;
3
4header! {
5 /// `Date` header, defined in [RFC7231](http://tools.ietf.org/html/rfc7231#section-7.1.1.2)
6 ///
7 /// The `Date` header field represents the date and time at which the
8 /// message was originated.
9 ///
10 /// # ABNF
11 ///
12 /// ```text
13 /// Date = HTTP-date
14 /// ```
15 ///
16 /// # Example values
17 ///
18 /// * `Tue, 15 Nov 1994 08:12:31 GMT`
19 ///
20 /// # Example
21 ///
22 /// ```rust
23 /// use actori_http::Response;
24 /// use actori_http::http::header::Date;
25 /// use std::time::SystemTime;
26 ///
27 /// let mut builder = Response::Ok();
28 /// builder.set(Date(SystemTime::now().into()));
29 /// ```
30 (Date, DATE) => [HttpDate]
31
32 test_date {
33 test_header!(test1, vec![b"Tue, 15 Nov 1994 08:12:31 GMT"]);
34 }
35}
36
37impl Date {
38 /// Create a date instance set to the current system time
39 pub fn now() -> Date {
40 Date(SystemTime::now().into())
41 }
42}