Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

244
Visualizações
Trying to get moment to convert month to Number but i get incorrect value

Need help figuring out why moment is returning incorrect value. This is the problem i am facing. At anytime i can get either a french or english value. For example if cMon = "août 2022" when this code runs cNMon returns 2 instead of 8

i tried passing locale but the issue is it needs to be able to accept either french or english and display the correct value.

Line of typescript code

import moment from 'moment';


private static async getCurrent(actor: Actor): Promise<{ Mon: string, Year: number, MonStr: string, NMon: number}> {
        let cMon = await actor.requestTo(GetElementText.for(cmon));
        let Year = Number(currMonthText.split(" ")[1]);
        let MonStr = currMonthText.split(" ")[0];
        let cNMon: number  = Number(moment().month(currMonthStr.trim()).format("M"));

   

        return { cMon, Year, MonStr, NMon }
    }
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda