[英]Liquid parsing date incorrectly
我有一個帶有以下代碼的文件standard_en.html
:
<td class="title">Date of Birth</td>
<td colspan="2">
{{ meta/birth_date | date: "%m/%d/%Y" }}
</td>
這將輸出08/18/1970
,這是錯誤的日期。
如果僅用{{ meta }}
替換液體管線,則會輸出:
{"source_url"=>"http://vdocs-jg/forms/goodlife/standard.html?__launch_signing__=true&customer_name=John%20Doe&gender__male=true&birth_date_DAY=8&birth_date_MONTH=8&birth_date_YEAR=1988&address=675%20Hermione%20Street&city=Lawrencetown&state_id=MA&postal=01823&ctn=4136743582&business_phone=4156328553&business_extension=93&drivers_license=TWACI2345&email=me@me.com&email_okay=true&employer_name=Southwest%20Electric&employer_phone=4032453564&emergency_contact=Gerald&emergency_phone=4564244543&referred_by=Steve%20Murphy&referred_number=546642",
"source_type"=>"html",
"terminal_lang"=>"en",
"dba"=>"wirelesswave",
"country"=>"CA",
"terminal_id"=>2,
"contract_lang"=>"en",
"contract_parser"=>"web_form",
"contract_with"=>"carrier",
"carrier"=>"goodlife",
"customer_name"=>"John Doe",
"gender"=>"male",
"birth_date"=>"19880808",
"contract_template"=>"goodlife_standard_1",
"industry_type"=>"cellular",
"pos_status"=>"unknown",
"tran_id"=>"20110816161001_4136743582"}
(為便於閱讀而格式化,刪除了一些信息)
如您所見,birth_date是“ 19880808”,這是我的測試所期望的值。 甚至在我們從中得出該日期的source_url中,也已正確設置了( birth_date_DAY=8&birth_date_MONTH=8&birth_date_YEAR=1988
)
另外一些附近的線路
<td class="title">Address</td>
<td>{{ meta/address }}</td>
<td class="title">City</td>
<td>{{ meta/city }}</td>
行為正確。
為什么Liquid會發布這個看似隨機的日期? 可以從其他地方播種嗎?
19880808
是Unix格式的日期。 即這不是1988-08-08,這不是1970-08-18(或+3時區中的19)。
$ ~ irb
2.1.0 :001 > Time.at(19880808)
=> 1970-08-19 05:26:48 +0300
如果你想顯示19880808
為1988-08-08
,你應該在使用前解析在Date#strptime
方法,之后將其轉換為您的日期格式。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.