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

Timezone America/Sao_Paulo is not consistent #5

Closed
mfandre opened this issue Jan 27, 2023 · 2 comments
Closed

Timezone America/Sao_Paulo is not consistent #5

mfandre opened this issue Jan 27, 2023 · 2 comments

Comments

@mfandre
Copy link

mfandre commented Jan 27, 2023

This example wont work, it should return available true. :(

import { getSlots } from "slot-calculator";
import { DateTime, Settings } from "luxon";
//Settings.defaultZone = "UTC";
const dateTimeRef = DateTime.utc(2023, 1, 24);
const weekday = dateTimeRef.weekdayLong;
console.log(weekday)

const allSlots = getSlots({
  from: "2023-01-24T12:00:00-03:00",
  to: "2023-01-24T13:00:00-03:00", 
  outputTimezone: "America/Sao_Paulo",
  duration: 60,
  unavailability:[],
  availability: [
    {
        day: "segunda",
        from: "09:00",
        to: "19:00",
        timezone: "America/Sao_Paulo"
    },{
        day: "terca-feira",
        from: "01:00",
        to: "23:00",
        timezone: "America/Sao_Paulo"
    },
    {
        day: "quarta-feira",
        from: "09:00",
        to: "19:00",
        timezone: "America/Sao_Paulo"
    },
    {
        day: "quinta-feira",
        from: "09:00",
        to: "19:00",
        timezone: "America/Sao_Paulo"
    },
    {
        day: "sexta-feira",
        from: "09:00",
        to: "19:00",
        timezone: "America/Sao_Paulo"
    }
  ]
});

console.log(allSlots);

@huzaifahj
Copy link
Owner

Thanks for creating this issue @mfandre

I believe this is because you are entering weekdays like segunda instead of Monday.

Internationalisation could definitely be better supported for weekdays, I will look into this for you

@huzaifahj
Copy link
Owner

@mfandre Fixed in latest release 7d0b064

You can now do something like this:

getSlots({
  from: dateTimeRef.plus({ hour: 3 }).toISO(),
  to: dateTimeRef.plus({ hour: 5 }).toISO(),
  outputTimezone: "America/Sao_Paulo",
  duration: 60,
  availability: [
    {
      day: {
        text: "sábado",
        locale: "pt-br",
      },
      from: "00:00",
      to: "01:00",
      timezone: "America/Sao_Paulo",
    },
  ],
})

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

No branches or pull requests

2 participants