strnow 1.0.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +66 -9
  3. package/dist/strnow.cjs +36 -0
  4. package/dist/strnow.js +12 -0
  5. package/package.json +42 -11
  6. package/demo.js +0 -3
  7. package/docs/asset-manifest.json +0 -25
  8. package/docs/favicon.ico +0 -0
  9. package/docs/index.html +0 -1
  10. package/docs/logo192.png +0 -0
  11. package/docs/logo512.png +0 -0
  12. package/docs/manifest.json +0 -25
  13. package/docs/precache-manifest.bb2fdff31f6c4ecc48e906f867f88907.js +0 -30
  14. package/docs/robots.txt +0 -3
  15. package/docs/service-worker.js +0 -39
  16. package/docs/static/css/2.de424728.chunk.css +0 -7
  17. package/docs/static/css/2.de424728.chunk.css.map +0 -1
  18. package/docs/static/css/main.c2c1f5e2.chunk.css +0 -15
  19. package/docs/static/css/main.c2c1f5e2.chunk.css.map +0 -1
  20. package/docs/static/js/2.e17ed3b5.chunk.js +0 -3
  21. package/docs/static/js/2.e17ed3b5.chunk.js.LICENSE.txt +0 -38
  22. package/docs/static/js/2.e17ed3b5.chunk.js.map +0 -1
  23. package/docs/static/js/main.5360092b.chunk.js +0 -2
  24. package/docs/static/js/main.5360092b.chunk.js.map +0 -1
  25. package/docs/static/js/runtime-main.f74c613d.js +0 -2
  26. package/docs/static/js/runtime-main.f74c613d.js.map +0 -1
  27. package/page/README.md +0 -68
  28. package/page/package-lock.json +0 -13503
  29. package/page/package.json +0 -45
  30. package/page/public/favicon.ico +0 -0
  31. package/page/public/index.html +0 -44
  32. package/page/public/logo192.png +0 -0
  33. package/page/public/logo512.png +0 -0
  34. package/page/public/manifest.json +0 -25
  35. package/page/public/robots.txt +0 -3
  36. package/page/src/App.css +0 -38
  37. package/page/src/App.js +0 -18
  38. package/page/src/App.test.js +0 -9
  39. package/page/src/Components/Header/index.js +0 -21
  40. package/page/src/Components/Header/style.css +0 -3
  41. package/page/src/css/bootstrap.dark.min.css +0 -12
  42. package/page/src/index.css +0 -13
  43. package/page/src/index.js +0 -17
  44. package/page/src/logo.svg +0 -7
  45. package/page/src/serviceWorker.js +0 -141
  46. package/page/src/setupTests.js +0 -5
  47. package/strnow.js +0 -6
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 marceloxp / strnow
3
+ Copyright (c) 2026 marceloxp / strnow
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,23 +1,80 @@
1
1
  # strnow
2
2
 
3
- > Get formated date and time (YYYY-MM-DD HH:mm:ss)
3
+ [![npm version](https://img.shields.io/npm/v/strnow.svg)](https://www.npmjs.com/package/strnow)
4
+ [![License](https://img.shields.io/npm/l/strnow.svg)](https://github.com/marceloxp/strnow/blob/master/LICENSE)
5
+ [![Downloads](https://img.shields.io/npm/dm/strnow.svg)](https://www.npmjs.com/package/strnow)
6
+ [![Test](https://github.com/marceloxp/strnow/actions/workflows/test.yml/badge.svg)](https://github.com/marceloxp/strnow/actions/workflows/test.yml)
4
7
 
5
- [![npm version](https://badge.fury.io/js/strnow.svg)](https://badge.fury.io/js/strnow) [![](https://data.jsdelivr.com/v1/package/npm/strnow/badge)](https://www.jsdelivr.com/package/npm/strnow) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+ **Returns current date and time in `YYYY-MM-DD HH:mm:ss` format** – simple and lightweight.
6
9
 
10
+ Fully supports **ESM** and **CommonJS** (dual package), using the latest version of `date-and-time`.
7
11
 
8
12
  ## Installation
9
13
 
10
- `yarn add strnow --dev`
11
-
12
- or
14
+ ```bash
15
+ npm install strnow
16
+ ```
13
17
 
14
- `npm install strnow --save-dev`
18
+ ```bash
19
+ yarn add strnow
20
+ ```
15
21
 
16
22
  ## Usage
17
23
 
24
+ ### ESM (import) — Recommended
25
+
26
+ ```javascript
27
+ import strnow from 'strnow';
28
+
29
+ console.log(strnow.get());
30
+ // Output: 2026-04-05 14:30:25
31
+
32
+ // Or using named import
33
+ import { get } from 'strnow';
34
+
35
+ console.log(get());
36
+ // Output: 2026-04-05 14:30:25
37
+ ```
38
+
39
+ ### CommonJS (require)
40
+
18
41
  ```javascript
19
42
  const strnow = require('strnow');
20
- const str_now = strnow.get();
21
- console.log(str_now);
22
- // OUTPUT EXAMPLE: 2018-07-19 14:21:40
43
+
44
+ console.log(strnow.get());
45
+ // Output: 2026-04-05 14:30:25
23
46
  ```
47
+
48
+ ### TypeScript
49
+
50
+ Type definitions are included.
51
+
52
+ ```typescript
53
+ import strnow from 'strnow';
54
+ // or
55
+ import { get } from 'strnow';
56
+
57
+ const now: string = strnow.get();
58
+ console.log(now);
59
+ ```
60
+
61
+ ## API
62
+
63
+ | Method | Description | Returns |
64
+ |----------------|--------------------------------------|---------|
65
+ | `get()` | Returns formatted current date/time | `string` |
66
+ | `default.get()`| Alias for compatibility | `string` |
67
+
68
+ **Fixed format:** `YYYY-MM-DD HH:mm:ss` (e.g., `2026-04-05 14:30:25`)
69
+
70
+ ## Why strnow?
71
+
72
+ - ✅ **Extremely lightweight** – minimal wrapper
73
+ - ✅ **Dual module** (ESM + CommonJS) – works in any Node.js project
74
+ - ✅ **Zero configuration** – minimal, predictable API
75
+ - ✅ **Single well-maintained dependency:** `date-and-time`
76
+ - ✅ **Tested and compatible with Node.js 18+**
77
+
78
+ ## License
79
+
80
+ MIT © [marceloxp](https://github.com/marceloxp)
@@ -0,0 +1,36 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/strnow.js
20
+ var strnow_exports = {};
21
+ __export(strnow_exports, {
22
+ default: () => strnow_default,
23
+ get: () => get
24
+ });
25
+ module.exports = __toCommonJS(strnow_exports);
26
+ var import_date_and_time = require("date-and-time");
27
+ var get = () => {
28
+ return (0, import_date_and_time.format)(/* @__PURE__ */ new Date(), "YYYY-MM-DD HH:mm:ss");
29
+ };
30
+ var strnow_default = {
31
+ get
32
+ };
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ get
36
+ });
package/dist/strnow.js ADDED
@@ -0,0 +1,12 @@
1
+ // src/strnow.js
2
+ import { format } from "date-and-time";
3
+ var get = () => {
4
+ return format(/* @__PURE__ */ new Date(), "YYYY-MM-DD HH:mm:ss");
5
+ };
6
+ var strnow_default = {
7
+ get
8
+ };
9
+ export {
10
+ strnow_default as default,
11
+ get
12
+ };
package/package.json CHANGED
@@ -1,12 +1,43 @@
1
1
  {
2
- "name": "strnow",
3
- "version": "1.0.2",
4
- "description": "Get formated date and time (YYYY-MM-DD HH:mm:ss)",
5
- "main": "strnow.js",
6
- "repository": "git@github.com:marceloxp/strnow.git",
7
- "author": "MarceloXP <marceloxp@gmail.com>",
8
- "license": "MIT",
9
- "dependencies": {
10
- "date-and-time": "^2.4.1"
11
- }
12
- }
2
+ "name": "strnow",
3
+ "version": "2.0.0",
4
+ "description": "Get current date and time formatted as YYYY-MM-DD HH:mm:ss",
5
+ "author": "marceloxp",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/marceloxp/strnow.git"
10
+ },
11
+ "type": "module",
12
+ "main": "./dist/strnow.cjs",
13
+ "module": "./dist/strnow.js",
14
+ "exports": {
15
+ ".": {
16
+ "import": "./dist/strnow.js",
17
+ "require": "./dist/strnow.cjs"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "scripts": {
24
+ "build": "node build.js",
25
+ "test": "node --test test/*.test.js",
26
+ "test:source": "node --test test/source.test.js",
27
+ "test:build": "npm run build && node --test test/build.test.js",
28
+ "prepublishOnly": "npm run build && npm test"
29
+ },
30
+ "dependencies": {
31
+ "date-and-time": "^4.4.0"
32
+ },
33
+ "devDependencies": {
34
+ "esbuild": "^0.25.0"
35
+ },
36
+ "keywords": [
37
+ "date",
38
+ "time",
39
+ "now",
40
+ "format",
41
+ "YYYY-MM-DD"
42
+ ]
43
+ }
package/demo.js DELETED
@@ -1,3 +0,0 @@
1
- const strnow = require('./strnow');
2
- const str_now = strnow.get();
3
- console.log(str_now);
@@ -1,25 +0,0 @@
1
- {
2
- "files": {
3
- "main.css": "/strnow/static/css/main.c2c1f5e2.chunk.css",
4
- "main.js": "/strnow/static/js/main.5360092b.chunk.js",
5
- "main.js.map": "/strnow/static/js/main.5360092b.chunk.js.map",
6
- "runtime-main.js": "/strnow/static/js/runtime-main.f74c613d.js",
7
- "runtime-main.js.map": "/strnow/static/js/runtime-main.f74c613d.js.map",
8
- "static/css/2.de424728.chunk.css": "/strnow/static/css/2.de424728.chunk.css",
9
- "static/js/2.e17ed3b5.chunk.js": "/strnow/static/js/2.e17ed3b5.chunk.js",
10
- "static/js/2.e17ed3b5.chunk.js.map": "/strnow/static/js/2.e17ed3b5.chunk.js.map",
11
- "index.html": "/strnow/index.html",
12
- "precache-manifest.bb2fdff31f6c4ecc48e906f867f88907.js": "/strnow/precache-manifest.bb2fdff31f6c4ecc48e906f867f88907.js",
13
- "service-worker.js": "/strnow/service-worker.js",
14
- "static/css/2.de424728.chunk.css.map": "/strnow/static/css/2.de424728.chunk.css.map",
15
- "static/css/main.c2c1f5e2.chunk.css.map": "/strnow/static/css/main.c2c1f5e2.chunk.css.map",
16
- "static/js/2.e17ed3b5.chunk.js.LICENSE.txt": "/strnow/static/js/2.e17ed3b5.chunk.js.LICENSE.txt"
17
- },
18
- "entrypoints": [
19
- "static/js/runtime-main.f74c613d.js",
20
- "static/css/2.de424728.chunk.css",
21
- "static/js/2.e17ed3b5.chunk.js",
22
- "static/css/main.c2c1f5e2.chunk.css",
23
- "static/js/main.5360092b.chunk.js"
24
- ]
25
- }
package/docs/favicon.ico DELETED
Binary file
package/docs/index.html DELETED
@@ -1 +0,0 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/strnow/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Get formated date and time (YYYY-MM-DD HH:mm:ss)"/><link rel="apple-touch-icon" href="/strnow/logo192.png"/><link rel="manifest" href="/strnow/manifest.json"/><title>StrNow - Demo</title><link href="/strnow/static/css/2.de424728.chunk.css" rel="stylesheet"><link href="/strnow/static/css/main.c2c1f5e2.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><a href="https://github.com/marceloxp/strnow" target="_blank" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#70b7fd;color:#fff;position:absolute;top:0;border:0;right:0" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin:130px 106px" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style><div id="root"></div><script>!function(e){function r(r){for(var n,l,a=r[0],p=r[1],f=r[2],c=0,s=[];c<a.length;c++)l=a[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in p)Object.prototype.hasOwnProperty.call(p,n)&&(e[n]=p[n]);for(i&&i(r);s.length;)s.shift()();return u.push.apply(u,f||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,a=1;a<t.length;a++){var p=t[a];0!==o[p]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={1:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="/strnow/";var a=this.webpackJsonppage=this.webpackJsonppage||[],p=a.push.bind(a);a.push=r,a=a.slice();for(var f=0;f<a.length;f++)r(a[f]);var i=p;t()}([])</script><script src="/strnow/static/js/2.e17ed3b5.chunk.js"></script><script src="/strnow/static/js/main.5360092b.chunk.js"></script></body></html>
package/docs/logo192.png DELETED
Binary file
package/docs/logo512.png DELETED
Binary file
@@ -1,25 +0,0 @@
1
- {
2
- "short_name": "React App",
3
- "name": "Create React App Sample",
4
- "icons": [
5
- {
6
- "src": "favicon.ico",
7
- "sizes": "64x64 32x32 24x24 16x16",
8
- "type": "image/x-icon"
9
- },
10
- {
11
- "src": "logo192.png",
12
- "type": "image/png",
13
- "sizes": "192x192"
14
- },
15
- {
16
- "src": "logo512.png",
17
- "type": "image/png",
18
- "sizes": "512x512"
19
- }
20
- ],
21
- "start_url": ".",
22
- "display": "standalone",
23
- "theme_color": "#000000",
24
- "background_color": "#ffffff"
25
- }
@@ -1,30 +0,0 @@
1
- self.__precacheManifest = (self.__precacheManifest || []).concat([
2
- {
3
- "revision": "0ebadbc65e79423f5d553f66b9b04864",
4
- "url": "/strnow/index.html"
5
- },
6
- {
7
- "revision": "bb187fa535f8bcd66b3f",
8
- "url": "/strnow/static/css/2.de424728.chunk.css"
9
- },
10
- {
11
- "revision": "f406f8e56b3bbfe01d05",
12
- "url": "/strnow/static/css/main.c2c1f5e2.chunk.css"
13
- },
14
- {
15
- "revision": "bb187fa535f8bcd66b3f",
16
- "url": "/strnow/static/js/2.e17ed3b5.chunk.js"
17
- },
18
- {
19
- "revision": "5ac48c47bb3912b14c2d8de4f56d5ae8",
20
- "url": "/strnow/static/js/2.e17ed3b5.chunk.js.LICENSE.txt"
21
- },
22
- {
23
- "revision": "f406f8e56b3bbfe01d05",
24
- "url": "/strnow/static/js/main.5360092b.chunk.js"
25
- },
26
- {
27
- "revision": "e79eb9477c7153c2b90f",
28
- "url": "/strnow/static/js/runtime-main.f74c613d.js"
29
- }
30
- ]);
package/docs/robots.txt DELETED
@@ -1,3 +0,0 @@
1
- # https://www.robotstxt.org/robotstxt.html
2
- User-agent: *
3
- Disallow:
@@ -1,39 +0,0 @@
1
- /**
2
- * Welcome to your Workbox-powered service worker!
3
- *
4
- * You'll need to register this file in your web app and you should
5
- * disable HTTP caching for this file too.
6
- * See https://goo.gl/nhQhGp
7
- *
8
- * The rest of the code is auto-generated. Please don't update this file
9
- * directly; instead, make changes to your Workbox build configuration
10
- * and re-run your build process.
11
- * See https://goo.gl/2aRDsh
12
- */
13
-
14
- importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
15
-
16
- importScripts(
17
- "/strnow/precache-manifest.bb2fdff31f6c4ecc48e906f867f88907.js"
18
- );
19
-
20
- self.addEventListener('message', (event) => {
21
- if (event.data && event.data.type === 'SKIP_WAITING') {
22
- self.skipWaiting();
23
- }
24
- });
25
-
26
- workbox.core.clientsClaim();
27
-
28
- /**
29
- * The workboxSW.precacheAndRoute() method efficiently caches and responds to
30
- * requests for URLs in the manifest.
31
- * See https://goo.gl/S9QRab
32
- */
33
- self.__precacheManifest = [].concat(self.__precacheManifest || []);
34
- workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
35
-
36
- workbox.routing.registerNavigationRoute(workbox.precaching.getCacheKeyForURL("/strnow/index.html"), {
37
-
38
- blacklist: [/^\/_/,/\/[^/?]+\.[^/]+$/],
39
- });