Skip to content

Commit

Permalink
Support SysTime as an element's text value.
Browse files Browse the repository at this point in the history
  • Loading branch information
FeepingCreature committed Jul 26, 2024
1 parent 3a17fb7 commit 42ec404
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/text/xml/Encode.d
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private void encodeNode(T, attributes...)(ref XMLWriter!(Appender!string) writer
}
else static if (udaIndex!(Xml.Text, memberAttrs) != -1)
{
writer.writeText(memberValue.encodeText, Newline.no);
writer.writeText(encodeLeafImpl(memberValue).encodeText, Newline.no);
}
else static if (is(typeof(cast() memberValue) : SumType!U, U...))
{
Expand Down
19 changes: 19 additions & 0 deletions unittest/text/xml/EncodeTest.d
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,22 @@ unittest
// then
text.should.equal(`<Container><Value value="1"/><Value value="2"/><Value value="3"/></Container>`);
}

@("SysTime as text")
unittest
{
@(Xml.Element)
struct Value
{
@(Xml.Text)
SysTime time;

mixin(GenerateThis);
}

// when
const text = Value(SysTime.fromISOExtString("2003-02-01T12:00:00")).encode;

// then
text.should.equal(`<Value>2003-02-01T12:00:00</Value>`);
}

0 comments on commit 42ec404

Please sign in to comment.