mirror of
https://github.com/lune-org/lune.git
synced 2025-05-04 10:43:57 +01:00
fix: DateTime::from_iso_date
DateTimeBuilder.to_string had a faulty template str for the ISO 8601 DateTime parsing.
This commit is contained in:
parent
4768134e6f
commit
a78ed4e122
3 changed files with 5 additions and 7 deletions
|
@ -174,7 +174,6 @@ impl<'lua> FromLua<'lua> for DateTimeBuilder {
|
|||
match value {
|
||||
LuaValue::Table(t) => Ok(Self::default()
|
||||
.with_year(t.get("year")?)
|
||||
// FIXME: Months are offset by two, months start on march for some reason...
|
||||
.with_month(
|
||||
(match t.get("month")? {
|
||||
LuaValue::String(str) => Ok(str.to_str()?.parse::<Month>().or(Err(
|
||||
|
|
|
@ -142,8 +142,10 @@ impl DateTime {
|
|||
where
|
||||
T: ToString,
|
||||
{
|
||||
let time =
|
||||
ChronoDateTime::parse_from_str(iso_date.to_string().as_str(), "%Y-%m-%dT%H:%M:%SZ")
|
||||
let time = ChronoDateTime::parse_from_str(
|
||||
format!("{}{}", iso_date.to_string(), "UTC+0000").as_str(),
|
||||
"%Y-%m-%dT%H:%M:%SZUTC%z",
|
||||
)
|
||||
.ok()?;
|
||||
|
||||
Some(Self {
|
||||
|
|
|
@ -10,7 +10,6 @@ use self::{
|
|||
use crate::lune::util::TableBuilder;
|
||||
|
||||
// TODO: Proper error handling and stuff
|
||||
// FIX: DateTime::from_iso_date is broken
|
||||
// FIX: fromUnixTimestamp calculation is broken
|
||||
|
||||
pub fn create(lua: &'static Lua) -> LuaResult<LuaTable> {
|
||||
|
@ -104,8 +103,6 @@ impl LuaUserData for DateTime {
|
|||
}
|
||||
|
||||
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
|
||||
methods.add_method("now", |_, _this, ()| Ok(DateTime::now()));
|
||||
|
||||
methods.add_method("toIsoDate", |_, this, ()| Ok(this.to_iso_date()));
|
||||
|
||||
methods.add_method(
|
||||
|
|
Loading…
Add table
Reference in a new issue