Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

timetable-fns

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timetable-fns - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

2

dist/timetable-fns.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("moment-timezone")):"function"==typeof define&&define.amd?define(["moment-timezone"],e):"object"==typeof exports?exports["timetable-fns"]=e(require("moment-timezone")):t["timetable-fns"]=e(t.moment)}("undefined"!=typeof self?self:this,function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(e,n){e.exports=t},function(t,e,n){"use strict";n.r(e);var r=n(0),o=n.n(r);const f=/^(\d{4})-(\d{2})-(\d{2})$/,u=/^(\d{2}):(\d{2})$/,i="Invalid";function a(t){const e=function(t){if(t&&"string"==typeof t){const e=f.exec(t);if(e)return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}return null}(t);if(!e||e.includes(NaN))return NaN;let[n,r,o]=e;return r=(r+9)%12,365*(n-=Math.floor(r/10))+Math.floor(n/4)-Math.floor(n/100)+Math.floor(n/400)+Math.floor((306*r+5)/10)+(o-1)}function c(t){if(Number.isNaN(t))return i;let e=Math.floor((1e4*t+14780)/3652425),n=t-(365*e+Math.floor(e/4)-Math.floor(e/100)+Math.floor(e/400));n<0&&(n=t-(365*(e-=1)+Math.floor(e/4)-Math.floor(e/100)+Math.floor(e/400)));let r=Math.floor((100*n+52)/3060),o=(r+2)%12+1;return l(e+=Math.floor((r+2)/12),o,n-Math.floor((306*r+5)/10)+1)}function l(t,e,n){return t.toString().padStart(4,"0")+"-"+e.toString().padStart(2,"0")+"-"+n.toString().padStart(2,"0")}e.default={coerce:function(t){return o.a.isMoment(t)?t.format("YYYY-MM-DD"):t},coerceTime:function(t){return o.a.isMoment(t)?t.format("HH:mm"):t},format:function(t){return o()(t,"YYYY-MM-DD",!0).format("L")},diff:function(t,e){return a(e)-a(t)},plus:function(t,e){return c(a(t)+e)},minus:function(t,e){return c(a(t)-e)},today:function(){const t=o()();return l(t.year(),t.month()+1,t.date())},valid:function(t){return t!==i&&t===c(a(t))},validTime:function(t){if(t&&"string"==typeof t){const e=u.exec(t);if(e){const t=parseInt(e[1]),n=parseInt(e[2]);return t>=0&&t<=23&&n>=0&&n<=59}}return!1}}}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("moment-timezone")):"function"==typeof define&&define.amd?define(["moment-timezone"],e):"object"==typeof exports?exports["timetable-fns"]=e(require("moment-timezone")):t["timetable-fns"]=e(t.moment)}("undefined"!=typeof self?self:this,function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(e,n){e.exports=t},function(t,e,n){"use strict";n.r(e),function(t){n.d(e,"coerce",function(){return d}),n.d(e,"coerceTime",function(){return s}),n.d(e,"format",function(){return p}),n.d(e,"diff",function(){return m}),n.d(e,"plus",function(){return b}),n.d(e,"minus",function(){return y}),n.d(e,"today",function(){return M}),n.d(e,"valid",function(){return h}),n.d(e,"validTime",function(){return x});var r=n(0),o=n.n(r);const u=/^(\d{4})-(\d{2})-(\d{2})$/,f=/^(\d{2}):(\d{2})$/,i="Invalid";function c(t){const e=function(t){if(t&&"string"==typeof t){const e=u.exec(t);if(e)return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}return null}(t);if(!e||e.includes(NaN))return NaN;let[n,r,o]=e;return r=(r+9)%12,365*(n-=Math.floor(r/10))+Math.floor(n/4)-Math.floor(n/100)+Math.floor(n/400)+Math.floor((306*r+5)/10)+(o-1)}function a(t){if(Number.isNaN(t))return i;let e=Math.floor((1e4*t+14780)/3652425),n=t-(365*e+Math.floor(e/4)-Math.floor(e/100)+Math.floor(e/400));n<0&&(n=t-(365*(e-=1)+Math.floor(e/4)-Math.floor(e/100)+Math.floor(e/400)));let r=Math.floor((100*n+52)/3060),o=(r+2)%12+1;return l(e+=Math.floor((r+2)/12),o,n-Math.floor((306*r+5)/10)+1)}function l(t,e,n){return t.toString().padStart(4,"0")+"-"+e.toString().padStart(2,"0")+"-"+n.toString().padStart(2,"0")}function d(t){return o.a.isMoment(t)?t.format("YYYY-MM-DD"):t}function s(t){return o.a.isMoment(t)?t.format("HH:mm"):t}function p(t){return o()(t,"YYYY-MM-DD",!0).format("L")}function m(t,e){return c(e)-c(t)}function b(t,e){return a(c(t)+e)}function y(t,e){return a(c(t)-e)}function M(){const t=o()();return l(t.year(),t.month()+1,t.date())}function h(t){return t!==i&&t===a(c(t))}function x(t){if(t&&"string"==typeof t){const e=f.exec(t);if(e){const t=parseInt(e[1]),n=parseInt(e[2]);return t>=0&&t<=23&&n>=0&&n<=59}}return!1}t.exports.default=t.exports}.call(this,n(2)(t))},function(t,e){t.exports=function(t){if(!t.webpackPolyfill){var e=Object.create(t);e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),Object.defineProperty(e,"exports",{enumerable:!0}),e.webpackPolyfill=1}return e}}])});
{
"name": "timetable-fns",
"version": "0.1.4",
"version": "0.1.5",
"description": "Useful date and time utility functions for working with timetables.",

@@ -5,0 +5,0 @@ "main": "dist/timetable-fns.js",

@@ -63,27 +63,27 @@ import moment from 'moment-timezone'

function coerce (dt) {
export function coerce (dt) {
return moment.isMoment(dt) ? dt.format('YYYY-MM-DD') : dt
}
function coerceTime (dt) {
export function coerceTime (dt) {
return moment.isMoment(dt) ? dt.format('HH:mm') : dt
}
function format (dt) {
export function format (dt) {
return moment(dt, 'YYYY-MM-DD', true).format('L')
}
function diff (a, b) {
export function diff (a, b) {
return _g(b) - _g(a)
}
function plus (dt, days) {
export function plus (dt, days) {
return _d(_g(dt) + days)
}
function minus (dt, days) {
export function minus (dt, days) {
return _d(_g(dt) - days)
}
function today () {
export function today () {
const m = moment()

@@ -93,7 +93,7 @@ return _str(m.year(), m.month() + 1, m.date())

function valid (dt) {
export function valid (dt) {
return dt !== INVALID && dt === _d(_g(dt))
}
function validTime (dt) {
export function validTime (dt) {
if (dt && typeof dt === 'string') {

@@ -110,12 +110,2 @@ const r = reTime.exec(dt)

export default {
coerce,
coerceTime,
format,
diff,
plus,
minus,
today,
valid,
validTime
}
module.exports.default = module.exports
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc