Code Monkey home page Code Monkey logo

challenge-javascript-12's Introduction

Uso de date-fns

La manipulación de fechas en JS puede ser compleja usando la lib de date-dns hace que sea más facíl.

RETO 1

Crear una función que retorne un array de filtros con base a una fecha, debe contener:

  • Últimos 7 días.
  • Últimos 28 días.
  • Últimos 90 días.
  • Últimos 365 días.
  • Filtros de los últimos 3 años.
  • Filtros de los últimos 3 meses.

Ejemplo: (con base en new Date(2020,0,1) como fecha de entrada)

[
  {
    label: 'Últimos 7 días',
    startAt: '2019/12/25',
    endAt: '2020/01/01'
  },
  {
    label: 'Últimos 28 días',
    startAt: '2019/12/04',
    endAt: '2020/01/01'
  },
  {
    label: 'Últimos 90 días',
    startAt: '2019/10/03',
    endAt: '2020/01/01'
  },
  {
    label: 'Últimos 365 días',
    startAt: '2019/01/01',
    endAt: '2020/01/01'
  },
  { label: '2019', startAt: '2019/01/01', endAt: '2019/12/31' },
  { label: '2018', startAt: '2018/01/01', endAt: '2018/12/31' },
  { label: '2017', startAt: '2017/01/01', endAt: '2017/12/31' },
  { label: 'diciembre', startAt: '2019/12/01', endAt: '2019/12/31' },
  { label: 'noviembre', startAt: '2019/11/01', endAt: '2019/11/30' },
  { label: 'octubre', startAt: '2019/10/01', endAt: '2019/10/31' }
]

Pasos

  1. Editar el archivo filter.js
  2. Construir los filtros en el método makeFilter

Instalación

npm install

test

npm run test

Enviar solución de reto

Debes hacer un "Fork" de este proyecto, revolver los problemas y crear un Pull Request hacia este repositorio.

Licencia

challenge-javascript-08 se lanza bajo la licencia MIT.

challenge-javascript-12's People

Contributors

nicobytes avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.