Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including time-to-days with all npm packages installed. Try it out:

var timeToDays = require("time-to-days")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

time-to-days v0.0.3

time-to-days

Convierte horas, dias, mes, años a dias

Instalación

npm install time-to-days

Importando libreria

Puedes importar de la siguiente forma:

import tdays from 'time-to-days'

Adicionalmente, puedes importar el módulo transpilado desde dist/lib:

import tdays from 'time-to-days/dist/lib/time-to-days'

Uso


let dias = 0.0;

// tiempo a dias
dias = tdays.timeToDays(10, 'hora') // 0.4
dias = tdays.timeToDays(1, 'dia') // 1
dias = tdays.timeToDays(2, 'mes') // 60
dias = tdays.timeToDays(2, 'año') // 730

// si pones el tipo diferente de hora, dia, mes, año
// retorna la misma cantidad
dias = tdays.timeToDays(5, 'tiempo') // 5

// dias a tiempo
dias = tdays.daysToTime(10, 'hora') // 240
dias = tdays.daysToTime(1, 'dia') // 1
dias = tdays.daysToTime(2, 'mes') // 0.7
dias = tdays.daysToTime(2, 'mes') // 0.07
dias = tdays.daysToTime(2, 'año') // 0.01

// si pones el tipo diferente de hora, dias, mes, año
// retorna la misma cantidad
dias = tdays.daysToTime(5, 'tiempo') // 5

Licencia

Licencia MIT. Ver archivo LICENCE

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free