speice.io/assets/js/16c8da5a.6e786399.js

1 line
17 KiB
JavaScript
Raw Permalink Normal View History

"use strict";(self.webpackChunkspeice_io=self.webpackChunkspeice_io||[]).push([["95"],{8066:function(e,t,n){n.r(t),n.d(t,{assets:function(){return l},contentTitle:function(){return r},default:function(){return d},frontMatter:function(){return o},metadata:function(){return i},toc:function(){return h}});var i=n(845),a=n(5893),s=n(65);let o={slug:"2018/06/dateutil-parser-to-rust",title:"What I learned porting dateutil to Rust",date:new Date("2018-06-25T12:00:00.000Z"),authors:["bspeice"],tags:[]},r=void 0,l={authorsImageUrls:[void 0]},h=[{value:"Slow down, what?",id:"slow-down-what",level:2},{value:"Lost in Translation",id:"lost-in-translation",level:2},{value:"Using a young language",id:"using-a-young-language",level:2},{value:"Trial Maintenance Policy",id:"trial-maintenance-policy",level:2},{value:"Roadmap and Conclusion",id:"roadmap-and-conclusion",level:2}];function c(e){let t={a:"a",blockquote:"blockquote",code:"code",em:"em",h2:"h2",img:"img",li:"li",ol:"ol",p:"p",strong:"strong",...(0,s.a)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(t.p,{children:["I've mostly been a lurker in Rust for a while, making a couple small contributions here and there.\nSo launching ",(0,a.jsx)(t.a,{href:"https://github.com/bspeice/dtparse",children:"dtparse"})," feels like nice step towards becoming a\nfunctioning member of society. But not too much, because then you know people start asking you to\npay bills, and ain't nobody got time for that."]}),"\n",(0,a.jsx)(t.p,{children:"But I built dtparse, and you can read about my thoughts on the process. Or don't. I won't tell you\nwhat to do with your life (but you should totally keep reading)."}),"\n",(0,a.jsx)(t.h2,{id:"slow-down-what",children:"Slow down, what?"}),"\n",(0,a.jsxs)(t.p,{children:["OK, fine, I guess I should start with ",(0,a.jsx)(t.em,{children:"why"})," someone would do this."]}),"\n",(0,a.jsxs)(t.p,{children:[(0,a.jsx)(t.a,{href:"https://github.com/dateutil/dateutil",children:"Dateutil"})," is a Python library for handling dates. The\nstandard library support for time in Python is kinda dope, but there are a lot of extras that go\ninto making it useful beyond just the ",(0,a.jsx)(t.a,{href:"https://docs.python.org/3.6/library/datetime.html",children:"datetime"}),"\nmodule. ",(0,a.jsx)(t.code,{children:"dateutil.parser"})," specifically is code to take all the super-weird time formats people come\nup with and turn them into something actually useful."]}),"\n",(0,a.jsxs)(t.p,{children:["Date/time parsing, it turns out, is just like everything else involving\n",(0,a.jsx)(t.a,{href:"https://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about-time",children:"computers"})," and\n",(0,a.jsx)(t.a,{href:"https://infiniteundo.com/post/25509354022/more-falsehoods-programmers-believe-about-time",children:"time"}),": it\nfeels like it shouldn't be that difficult to do, until you try to do it, and you realize that people\nsuck and this is why\n",(0,a.jsx)(t.a,{href:"https://zachholman.com/talk/utc-is-enough-for-everyone-right",children:"we can't we have nice things"}),". But\nalas, we'll try and make contemporary art out of the rubble and give it a pretentious name like\n",(0,a.jsx)(t.em,{children:"Time"}),"."]}),"\n",(0,a.jsx)(t.p,{children:(0,a.jsx)(t.img,{alt:"A gravel mound",src:n(9394).Z+"",width:"800",height:"374"})}),"\n",(0,a.jsxs)(t.blockquote,{children:["\n",(0,a.jsx)(t.p,{children:(0,a.jsx)(t.a,{href:"https://www.goodfreephotos.com/united-states/montana/elkhorn/remains-of-the-mining-operation-elkhorn.jpg.php",children:"Time"})}),"\n"]}),"\n",(0,a.jsxs)(t.p,{children:["What makes ",(0,a.jsx)(t.code,{children:"dateutil.parser"})," great is that there's single function with a single argument that\ndrives what programmers interact with:\n",(0,a.jsx)(t.a,{href:"https://github.com/dateutil/dateutil/blob/6dde5d6298cfb81a4c594a38439462799ed2aef2/dateutil/parser/_parser.py#L1258",children:(0,a.jsx)(t.code,{children:"parse(timestr)"})}),'.\nIt takes in the time as a string, and gives you back a reasonable "look, this is the best anyone can\np