@@ -56,6 +56,15 @@ mod data {
5656 Number ( u64 ) ,
5757 }
5858
59+ impl StrOrNumber {
60+ pub fn try_to_number ( & self ) -> Option < u64 > {
61+ match self {
62+ Self :: Str ( s) => s. parse :: < u64 > ( ) . ok ( ) ,
63+ Self :: Number ( n) => Some ( * n) ,
64+ }
65+ }
66+ }
67+
5968 impl Display for StrOrNumber {
6069 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
6170 match self {
@@ -108,9 +117,10 @@ mod data {
108117 impl ModuleAuthor {
109118 pub fn pub_time ( & self ) -> Option < u64 > {
110119 let pub_ts = match self {
111- ModuleAuthor :: Normal ( normal) => normal. pub_ts ,
112- ModuleAuthor :: Pgc ( pgc) => pgc. pub_ts ,
113- } ;
120+ ModuleAuthor :: Normal ( normal) => & normal. pub_ts ,
121+ ModuleAuthor :: Pgc ( pgc) => & pgc. pub_ts ,
122+ }
123+ . try_to_number ( ) ?;
114124 ( pub_ts != 0 ) . then_some ( pub_ts)
115125 }
116126 }
@@ -137,15 +147,15 @@ mod data {
137147 pub face : String , // URL
138148 pub mid : StrOrNumber ,
139149 pub name : String ,
140- pub pub_ts : u64 ,
150+ pub pub_ts : StrOrNumber ,
141151 }
142152
143153 #[ derive( Clone , Debug , Deserialize ) ]
144154 pub struct ModuleAuthorPgc {
145155 pub face : String , // URL
146156 pub mid : StrOrNumber ,
147157 pub name : String ,
148- pub pub_ts : u64 , // Always 0?
158+ pub pub_ts : StrOrNumber , // Always 0?
149159 }
150160
151161 #[ derive( Debug , Deserialize ) ]
0 commit comments