Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
Get list of days in the week that reflect locale in JavaScript?

I have this function that returns days of the week:

var SEPARATOR = '  ';
function week_days(lang) {
    var result = [];
    for (var i = 0; i <= 6; ++i) {
        var d = new Date(1970, 1, 1 + i);
        result.push(d.toLocaleString(lang, {weekday: 'short'}).substring(0, 2));
    }
    return result.join(SEPARATOR);
}

console.log("en-us", week_days("en-us"))
console.log("pl-pl", week_days("pl-pl"))

but it's fixed and starts from Sunday like in the US locale. But in the Polish locale week starts from Monday. There are probably languages that use one or the other.

I can use new Date(1970, 1, 2 + i); and it will work, but how I can make it based on Locale? (e.g. window.navigator.language).

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I've found that the spec has no way of knowing this information. It's tracked here:

https://github.com/tc39/ecma402/issues/6

This is an old issue. From the comments, it seems that there is a spec:

https://github.com/tc39/proposal-intl-locale-info

That should handle this.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda