Hello Rustaceans.
I'm starting my first big project in Rust.
I have quite a bit of experience programming in other languages, but it looks like Rust is the way of the future, so I thought I'd give it a shot.
I want to start a small gig, helping people in my neighborhood solve issues with their computers, for an extremely low price. I've started work on a website where I can explain what I do, and (eventually) let my customers reserve my available appointment times, and also provide their address, so I can find their house.
The main page is already finished. I'm using Rocket, with its Handlebars integration for templating. I want to make a page where users can see available dates and times, and select them. However, in order to do that, I need to find a way to input the available dates into my server, and parse them, and store them, and remove them when someone reserves one, etc.
Currently, I'm trying to use the chrono
crate, but I'm finding it extremely confusing, and I want to know if there's a better way.
Or, if there isn't, some sort of tutorial on how to use chrono
would be much appreciated, as I don't know where to look (DuckDuckGo doesn't usually yield good results when I look for Rust tutorials), and the documentation is too technical for me to follow.
I dont think you need chrono given that you have 1 server with 1 timezone you care about.
You can store things using the buildin datetime. And just. Check when these hours are booked or not.
The issue is if your server is not on the same timezone as you are. This is where you need chrono because you want to be able to get the current datetime in YOUR timezone.
If timezones are actually a thing you deal with then you should save things as unix time in your server. That avoids all kinds of potential bugs.
First, note that chrono isn't realy for parsing times unless your times are coming in a well formed structure that can be parsed by parse_from_str -- it will be if you produce your timestamps using javascript, but won't be if you are taking and-written user input. The other odd thing is that chrono doesn't include timezone support, you need an external crate (either chrono-tz which bundles the timezone database or tzfile which uses the system database). jiff is a newer time crate which intends to be a bit more intuitive and auto-includes a time zone database only if required by the platform. Its comparison to chrono may also make some things clearer even if you stick with chrono.
Thanks!
I'll check jiff
out.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.