https://github.com/allnulled/lsw-timer
Time parser and related tool for LSW
https://github.com/allnulled/lsw-timer
Last synced: about 1 year ago
JSON representation
Time parser and related tool for LSW
- Host: GitHub
- URL: https://github.com/allnulled/lsw-timer
- Owner: allnulled
- License: other
- Created: 2025-01-27T12:16:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-24T17:50:12.000Z (over 1 year ago)
- Last Synced: 2025-03-24T18:46:12.541Z (over 1 year ago)
- Language: JavaScript
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# lsw-timer
Parser simple para fecha, hora, rango, duración y lista.
Branch of [@allnulled/timeformat](https://github.com/allnulled/timeformat).
## Instalación
```sh
npm i -s @allnulled/lsw-timer
```
Y en node.js ya puedes:
```js
require("@allnulled/lsw-timer");
```
Y en html tienes que:
```html
```
## Uso
Tanto en node.js como en html puedes:
```js
const time = Timeformat_parser.parse("1h 5min 30s");
```
## Formatos válidos
Permite:
- duración: `0y 0mon 0d 0h 0min 0s 0ms`
- fecha: `2025/01/01`
- hora: `00:00:00.000`, `00:00:00`, `00:00`
- fecha y hora: `2025/01/01+00:00:00.000`
- rango de fecha y hora: `2025/01/01-2028/01/01`
- lista de los anteriores, usando `,` para separar
Un ejemplo de cada:
```js
const out1 = Timeformat_parser.parse("1h 20min");
const out2 = Timeformat_parser.parse("1y 2mon 5d 3h 2min 10s 15ms");
const out3 = Timeformat_parser.parse("1h, 2h, 3h");
const out4 = Timeformat_parser.parse("2025/01/01+00:00:00.000");
const out5 = Timeformat_parser.parse("2025/01/01+00:00:00.000-2025/01/01+00:00:01.000");
const out6 = Timeformat_parser.parse("2025/01/01-2028/01/01");
const out7 = Timeformat_parser.parse("2025/01/01-2028/01/01, 2030/01/01-2033/01/01");
```
## Casos de uso
Parseo simple de los tipos anteriores, no mucho más. En teoría estaba `moment.js` para cosas más más.