Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Year is missing when using DateTime.fromObject({birthDate}).toISODate() #1328

Closed
detoner777 opened this issue Nov 17, 2022 · 5 comments
Closed

Comments

@detoner777
Copy link

detoner777 commented Nov 17, 2022

Description
Weird bug, I use luxon with Next.js, and on my local machine it works great:

const date = DateTime.fromObject({year: 1999, month: 09, day: 09}).toISODate()
it returns date === '1999-09-09';

But after deployed to Vercel, the code above does not parse the year,
it returns date === '-09-09';

and I use the same machine and the same browser just a different tab.

  • macOS: 13.0
  • Browser: Chrome Version 107.0.5304.87 (Official Build) (x86_64)
  • Luxon version: "2.5.0"
  • Your timezone [e.g. "America/New_York"]
  • Next.js: "13.0.3"

The same happens in Firefox Browser and on other machines.

@detoner777 detoner777 changed the title Year is missing when using DateTime.fromObject({year: number, month: number>/}).toISODate() Year is missing when using DateTime.fromObject({birthDate}).toISODate() Nov 17, 2022
@icambron
Copy link
Member

Hard to tell if you're running into an issue parsing the date or in toISODate...

Can you provide the output of DateTime.fromObject({year: 1999, month: 09, day: 09}).toObject() and also just print out DateTime.fromObject({year: 1999, month: 09, day: 09})

@davecarlson
Copy link

davecarlson commented Nov 19, 2022

I can confirm i'm having the same issue on vercel on a new deployment. Luxon 3.1.0

works fine locally.
my luxon object:

c
: 
{year: 2022, month: 11, day: 14, hour: 0, minute: 0, …}
invalid
: 
null
isLuxonDateTime
: 
true
loc
: 
eK {locale: 'en-GB', numberingSystem: null, outputCalendar: null, intl: 'en-GB', weekdaysCache: {…}, …}
o
: 
-0
ts
: 
1668384000000
weekData
: 
null
_zone
: 
eb {}

@zachgoll
Copy link

By the looks of it, this commit should fix the issue on the Next.js side of things, still waiting for a release on that. In the meantime, setting swcMinify: false in next.config seems to fix.

@patdx
Copy link

patdx commented Nov 29, 2022

I had run into a similar issue with some code like DateTime.fromSQL(raw.ts, { zone: "Asia/Hong_Kong" }).toUTC().toISO(); After upgrading Next.js from 13.0.4 to 13.0.5 it went away.

@icambron
Copy link
Member

A minification issue makes sense to me. @zachgoll do you know what the root SWC issue and fix was?

At any rate, since this is fixed in the latest Next, closing this one out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants