From 881d2a258a95d4534242e671b5c97f48f6878d12 Mon Sep 17 00:00:00 2001 From: Robert burner Schadek Date: Mon, 19 Feb 2024 13:27:58 +0100 Subject: [PATCH] double to date fix This fixes a problem where double where incorrectly converted to Date's --- sample-xlsx2.xlsx | Bin 0 -> 5917 bytes source/xlsxreader.d | 9 ++++++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 sample-xlsx2.xlsx diff --git a/sample-xlsx2.xlsx b/sample-xlsx2.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..cec1ce9d5a36d87efc50485a9dc1f18cc83c350c GIT binary patch literal 5917 zcmaJ_2RK}7wbTWF0Haa6l@0}1ewf5fcx4w6+^=hi%;nUy{5fR}$uzaYGbHPZkzaP0m z9pQok=jYM{lzO`mX~dRqG|%DfX&Iv2!bVl4#_J;2-myDht$vc<5&He$K9HI;uCg8R zI3V!U0y(4V%r_&%sbcy>$Kc7OW=>20qK@v<$KHZ>dh-I_Q;9v$hRO4|#%n0=^~}qD zEbw)Es!aTKS50LAcg1qu3P(yN($z%A^VX?V)N+`?dMx#08{NFIK>VgKH7AGL&R}Ln zpL@a!daQ}pJ{b#vJ*kkA8dd7`RBv`a2m$|3>6IH!WE-j^9uPND~;EUF3 zL7Bpha|`#`7veYoWN%-nfD2Kw4;LgS#EOkUA`j^8SF2au;#?C7h3QS{HJfgBHb5vx zpad4a2N>p>l2;>hgXt$hDbo5%h+0sv#4wuJ`TI;y0ukPkc>B_G`lwG*gTfsqXHe;r z!jpk;1jGFRPK;Bh%jkEn7%hR>fciQt2!uq(y(5IZ*jHx!S5PSa0_7qcaSywkCxs}R z4|(xtpx_z%t0{PTh^IKylto?X35r)7qG`}ODS2lzR8S=MggnI^agy1lbZ^6%Oovq_ zlzy&GPo6AVQnOwlY@&00(sJ!nn$5G45S3CEYq~e<*89%hgVrzXnh(D=SKch4e6Bz_ z))bO48SE^hRWMw*tW-D-sJZ!$#0b}nKhzwg9-2YYDG?Ta#7t_E!WtRZM{%2L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GKy|Lo{k9v} zTm7?A_h+1oqQ$wK_1h$|{DO^hQQZ2|`QkKso?*Yu1^<`xpDM?n0m3izr{_cKZyP4~ z72x*>`={&0N_F1A{x&=;kbgh;|7mCcjB=4o&#T&R6TzbKn?V1raeumBm3?YEU Date.init, (long l) => longToDate(l), - (double l) => longToDate(lround(l)), + (double l) => doubleToDateTime(l).date, (string l) => stringToDate(l), (DateTime l) => l.date, (Date l) => l, @@ -1313,3 +1313,10 @@ unittest { assert(!a2.empty); assert(a2.front.value == "0012", format("%s", a2.front.value)); } + +unittest { + auto s = readSheet("sample-xlsx2.xlsx", "Sheet1"); + auto rslt = s.iterateColumn!Date(0, 1, 7).array; + auto toEqual = [ Date(2024,1,15), Date(2024,1,15), Date(2024,1,15), Date(2024,1,15), Date(2024,1,15), Date(2024,1,15)]; + assert(rslt == toEqual); +}