Skip to content

Commit

Permalink
Remove chrono dep
Browse files Browse the repository at this point in the history
  • Loading branch information
yukibtc committed Aug 18, 2024
1 parent ac7b4b7 commit 5f66045
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 90 deletions.
77 changes: 0 additions & 77 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ blocking = ["reqwest/blocking"]

[dependencies]
base64 = "0.22"
chrono = "0.4"
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls-webpki-roots", "socks"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
## Example

```toml
chrono = "0.4"
ntfy = "0.4"
tokio = { version = "1", features = ["full"] }
url = "2"
```

```rust,no_run
use chrono::{Duration, Local};
use ntfy::payload::{Action, ActionType};
use ntfy::{Auth, Dispatcher, NtfyError, Payload, Priority};
use url::Url;
Expand All @@ -44,7 +42,7 @@ async fn main() -> Result<(), NtfyError> {
.actions([action]) // Add optional actions
.click(Url::parse("https://example.com")?) // Add optional clickable url
.attach(Url::parse("https://example.com/file.jpg")?) // Add optional url attachment
.delay(Local::now() + Duration::minutes(1)) // Add optional delay
.delay(1639194738) // Add optional delay
.markdown(true); // Use markdown
dispatcher.send(&payload).await.unwrap();
Expand Down
3 changes: 1 addition & 2 deletions examples/blocking.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) 2022 Yuki Kishimoto
// Distributed under the MIT software license

use chrono::{Duration, Local};
use ntfy::payload::{Action, ActionType};
use ntfy::{Auth, Dispatcher, NtfyError, Payload, Priority};
use url::Url;
Expand All @@ -26,7 +25,7 @@ fn main() -> Result<(), NtfyError> {
.actions([action]) // Add optional actions
.click(Url::parse("https://example.com")?) // Add optional clickable url
.attach(Url::parse("https://example.com/file.jpg")?) // Add optional url attachment
.delay(Local::now() + Duration::minutes(1)) // Add optional delay
.delay(1639194738) // Add optional delay
.markdown(true); // Use markdown

dispatcher.send(&payload).unwrap();
Expand Down
3 changes: 1 addition & 2 deletions examples/client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) 2022 Yuki Kishimoto
// Distributed under the MIT software license

use chrono::{Duration, Local};
use ntfy::payload::{Action, ActionType};
use ntfy::{Auth, Dispatcher, NtfyError, Payload, Priority};
use url::Url;
Expand All @@ -27,7 +26,7 @@ async fn main() -> Result<(), NtfyError> {
.actions([action]) // Add optional actions
.click(Url::parse("https://example.com")?) // Add optional clickable url
.attach(Url::parse("https://example.com/file.jpg")?) // Add optional url attachment
.delay(Local::now() + Duration::minutes(1)) // Add optional delay
.delay(1639194738) // Add optional delay
.markdown(true); // Use markdown

dispatcher.send(&payload).await.unwrap();
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#[macro_use]
extern crate serde;

pub use chrono::{Duration, Local};
pub use url::Url;

pub mod dispatcher;
Expand Down
8 changes: 4 additions & 4 deletions src/payload/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) 2022 Yuki Kishimoto
// Distributed under the MIT software license

use chrono::{DateTime, Local};
use url::Url;

pub mod action;
Expand All @@ -22,7 +21,8 @@ pub struct Payload {
pub click: Option<Url>,
pub attach: Option<Url>,
pub filename: Option<String>,
pub delay: Option<String>,
/// Delay (UNIX timestamp)
pub delay: Option<u64>,
pub email: Option<String>,
#[serde(skip)]
pub markdown: bool,
Expand Down Expand Up @@ -122,8 +122,8 @@ impl Payload {

/// Set delay
#[inline]
pub fn delay(mut self, time: DateTime<Local>) -> Self {
self.delay = Some(time.timestamp().to_string());
pub fn delay(mut self, timestamp: u64) -> Self {
self.delay = Some(timestamp);
self
}

Expand Down

0 comments on commit 5f66045

Please sign in to comment.