Skip to content

Commit

Permalink
Disable use of std::time on wasm for SVG export
Browse files Browse the repository at this point in the history
  • Loading branch information
abey79 committed Sep 14, 2023
1 parent 1138621 commit 072492a
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions vsvg-core/src/svg_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
use svg::Node;

use crate::{DocumentTrait, LayerTrait, PathDataTrait, PathTrait, Polyline};
use time::format_description::well_known::Iso8601;
use time::OffsetDateTime;

// private trait in public types, see https://github.com/rust-lang/rust/issues/34537

Expand Down Expand Up @@ -129,13 +127,22 @@ pub(crate) fn document_to_svg_doc<
let mut dc_format = svg::node::element::Element::new("dc:format");
dc_format.append(svg::node::Text::new("image/svg+xml"));
cc.append(dc_format);
let mut dc_date = svg::node::element::Element::new("dc:date");
dc_date.append(svg::node::Text::new(
OffsetDateTime::now_utc()
.format(&Iso8601::DEFAULT)
.expect("must format"),
));
cc.append(dc_date);

//TODO: find suitable replacement
#[cfg(not(target_arch = "wasm32"))]
{
use time::format_description::well_known::Iso8601;
use time::OffsetDateTime;

let mut dc_date = svg::node::element::Element::new("dc:date");
dc_date.append(svg::node::Text::new(
OffsetDateTime::now_utc()
.format(&Iso8601::DEFAULT)
.expect("must format"),
));
cc.append(dc_date);
}

if let Some(source) = document.metadata().source.as_ref() {
let mut dc_source = svg::node::element::Element::new("dc:source");
dc_source.append(svg::node::Text::new(source));
Expand Down

0 comments on commit 072492a

Please sign in to comment.