1.0.0 • Published 12 days ago

@ryniaubenpm/adipisci-officiis-quis v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 days ago

🕉 @ryniaubenpm/adipisci-officiis-quis

💎 Install

pnpm add @ryniaubenpm/adipisci-officiis-quis

🤓 Unit Tests

Statements

🙏 Description

  • Simple function that recieves a Date object that is in the future or is in the past and gives back the relative time using Intl.RelativeTimeFormat('en', { numeric: 'auto' })
  • Examples: [ "last year", "6 months ago", "4 weeks ago", "7 days ago", "now", "in 1 minute", "in 6 hours", "tomorrow", "in 3 days", "in 4 weeks", "next month", "in 2 months", "in 12 months", "next year" ]

💚 Examples

import { getRelativeTime } from '@ryniaubenpm/adipisci-officiis-quis'

const d1 = new Date()
d1.setDate(d1.getDate() - 450)
getRelativeTime(d1) // last year

const d2 = new Date()
d2.setDate(d2.getDate() - 180)
getRelativeTime(d2) // 6 months ago

const d3 = new Date()
d3.setDate(d3.getDate() - 30)
getRelativeTime(d3) // 4 weeks ago

const d4 = new Date()
d4.setDate(d4.getDate() - 7)
getRelativeTime(d4) // 7 days ago

getRelativeTime(new Date()) // now
getRelativeTime(new Date((new Date()).getTime() + 60000)) // in 1 minute
getRelativeTime(new Date((new Date()).getTime() + 360 * 60000)) // in 6 hours
getRelativeTime(new Date((new Date()).getTime() + (1440 * 60000))) // tomorrow
getRelativeTime(new Date((new Date()).getTime() + (3 * 1440 * 60000))) // in 3 days
getRelativeTime(new Date((new Date()).getTime() + (28 * 1440 * 60000))) // in 4 weeks
getRelativeTime(new Date((new Date()).getTime() + (35 * 1440 * 60000))) // next month
getRelativeTime(new Date((new Date()).getTime() + (60 * 1440 * 60000))) // in 2 months
getRelativeTime(new Date((new Date()).getTime() + (365 * 1440 * 60000))) // in 12 months
getRelativeTime(new Date((new Date()).getTime() + (400 * 1440 * 60000))) // next year

🔥 Errors we may throw

  • getRelativeTime()
if (!(date instanceof Date) || date.toString() === 'Invalid Date') throw { id: 'fln__get-relative-time__invalid-date', message: 'Please pass getRelativeTime() a valid date object', _errorData: { date } }

🎁 All Our Packages

  1. @feelinglovelynow/datetime-local: NPMGithub
  2. @feelinglovelynow/dgraph: NPMGithub
  3. @feelinglovelynow/env-write: NPMGithub
  4. @feelinglovelynow/get-form-entries: NPMGithub
  5. @ryniaubenpm/adipisci-officiis-quis: NPMGithub
  6. @feelinglovelynow/global-style: NPMGithub
  7. @feelinglovelynow/jwt: NPMGithub
  8. @feelinglovelynow/loop-backwards: NPMGithub
  9. @feelinglovelynow/slug: NPMGithub
  10. @feelinglovelynow/svelte-catch: NPMGithub
  11. @feelinglovelynow/svelte-kv: NPMGithub
  12. @feelinglovelynow/svelte-loading-anchor: NPMGithub
  13. @feelinglovelynow/svelte-modal: NPMGithub
  14. @feelinglovelynow/svelte-turnstile: NPMGithub
  15. @feelinglovelynow/toast: NPMGithub
gesturesarraybuffergetterMicrosoftexebufferECMAScript 5escapeArrayBuffer.prototype.sliceinvariantlimitFloat32Arraydeepclonejson-schematypescriptRegExp#flagsfunctionsconststylinginputes-shimsduplexfixed-widthasyncdeep-cloneramdapushtapTypeScriptfsassignArray.prototype.includesschemees-shim APIPushruntimeopenersymlinksmiddlewareReactiveExtensionsYAMLloadingthrottlekarmalibphonenumberinternal slotrandomes2015astcomputed-typesstructuredClonedom-testing-librarysortedexecutablecss lessthroatbyteOffsetconnectiteratesettingsbabel-coreuser-streamses5RegExp.prototype.flagscmdstringifydebuggerhelpersavanodeflagforEachstring6to5matchloggerfull-widthauthenticationwordbreakclonemodulesless csscurriedcjkreadablestreamBigInt64ArrayclicontainsWebSocketlastbundlingdefaultrecursivemakeECMAScript 2015rm -rfwordwrapclassnamesanimationchannelpasswordsuperagentUnderscoreajvRxJSvariablesECMAScript 2022boundcopysyntaxinstallerflatimportObjectinternalsanitizationkeyclassnameObservablesetuuidimmerArray.prototype.flatconcatES2018enderutilityshimECMAScript 2016datepruneprettydeep-copyopenstoStringTagsequencetoolkitenvcharactersnopeoptionnegative zerodropcharacterscheme-validationcss nestingcolorJSON-Schemaemojichromiumcodesapiwidthjoicall-boundformperformantES5WeakMapRFC-6455starterletstartchineseregular expression.envexithttpsgroupByargumentbrowserregexidlebannernamereal-timetranspilevalidationTypedArraysharedtslibhttpcorsweaksetentriesgradients css3packageshampreprocessorqueryfigletCSSStyleDeclarationreact-testing-libraryeslintpluginbabelreducepackagesinspectlessprotobufspringmimejsonasciiwalkingmovemimetypesES7optimizertoSortedlintwrapes2017speedeslintsharedarraybufferstyleguidenegativeglobresolvewebsiteregular expressionspyyamljsAsyncIteratorunicodelook-upcommand-linespinnersvaluesnodejsES2022airbnbcallES2015touchgenericsES2019ES3rmpicomatchweakmappathxsssortclass-validatorextendutil.inspecthardlinksdomstyled-componentsflatMapbusyreduxprotocol-buffersfantasy-landESdescriptorlinewraphookformwriteReflect.getPrototypeOfsignaldeterministiconceconfigurablees-abstractdirxdgstreammacoscolourES2023Uint8ClampedArrayArrayttypopmotionarrayslookpureArray.prototype.flattenspinnermatchescss-in-jsrequireworkspace:*ECMAScript 2021typeofbcryptencryptionslicejQuerydeleteobjectzeroratelimitestreeparsestylesheetInt16Arrayautoprefixertypesjsonpathfast-copytrimStartUint32ArrayES8reducerthreeframerchildawaittermphoneoffsettimepositiveargvObservablescolumnsshellmulti-packagepackage managertoArraysuperstructextensionWeakSetobjcompile lesswatchdescriptorsauthcsshigher-orderpropfind-upless.jsdayjsjasmineECMAScript 7equalitytranspilermatchAllextrahooksfetchmergedataviewcall-bindbddterminalgetPrototypeOfrequestJSONenvironmentbluebirdesargparsetesterECMAScript 3logprotonameszodES6String.prototype.matchAllcore$.extendpromisestraverseiterationcallbinddependency managerwarningtypedarrayansisetterECMAScript 2018xhrfrommobilegetoptwalkarktypekeysassertscircularsyntaxerrorgdprpropertiesECMAScript 2019statelessuninstallregexpECMAScript 6less compilertacittc39expressprivatewgetstringifiercryptqsjsonschemashrinkwrapvalidatorArray.prototype.filterexit-codejavascriptHyBijson-schema-validatormetadataeditorsidedatastructureexpressionirqchaii18npostcssbrowserlistwatchFilecreatetddstreamseveryquotefindupquerystringserializermonorepofile systemconsumemrucacheObject.keysfast-cloneUint8Arraylength_.extendstatusES2016operating-systemfindLastIndexfastArray.prototype.findLastmaptypeerrortestingreusefolderidreacttyped arrayreadhandlersWebSocketsreact poselaunchgradients cssInt8Arraycheckjestfpfastifyless mixinsprototypeTypeBoxcommandermkdirswhatwgspawntrimLeftES2020writableremovefastcopyArray.prototype.flatMapassertmake dirfindLastES2021ArrayBuffererror-handlingdeepcopypnpm9typedarraysredux-toolkitdebugbrowserslistvalidateInt32ArraytypedObject.valuestestsignalstoolsECMAScript 2020mkdirpbyteLengthinferenceworkermoduleprocessiteratorprivate dataindicatorReactiveXaccessorrangeerrorbytedefinetelephoneECMAScript 2023callbackequaltrimRightjsdomstreams2takehashtoobjectrapidcode pointsintrinsiceventsdescriptionArray.prototype.containsSetBigUint64Arraysanitizefast-deep-cloneecmascriptflagsPromiseStreamsbindiscryptodiffsetImmediatestable-0yupreact animationpatchfunctionalcommandvalidponyfillcompareprogressformsSymbol.toStringTagconcatMaptypaniontypesafedatafunctionStreamconfigcollection3dpostcss-plugingetclassesnativepreserve-symlinksassertionjson-schema-validationformatemitserializestylesratelrubootstrap csscensorminimallesscssxtermutil@@toStringTagES2017schemasymbollinkrobustjapanesevisualECMAScript 2017mime-dbutilsformattingoutputconsolehasOwninterruptsdirectorywhichopenrm -frmixinsinstallreact-hook-formawesomesaucees8groupdependenciesdotenvexecqueueurlsapolloString.prototype.trimeslint-pluginpromiseUint16Arraycore-jscolumnstylepluginlimitedObject.assignpropertyqueueMicrotasksymlinksigintlockfileObject.entriesfindObject.definePropertyajax__proto__rmdirarrayspecomitpipepolyfillyamlargumentssigtermchromecollection.es6type0point-freedragsomemomentvaluesafelazyeast-asian-widthviewwatcherparserposeframeworkFunction.prototype.name256jwtisConcatSpreadabletrimlanguagebatchSymboles2016Object.getPrototypeOfreadableparentsgetOwnPropertyDescriptorbundlertapevariables in cssoptimistenumerablel10nfast-deep-copyxdg-openwaittrimEndshebangparentnested cssargsIteratorflattenredactreact-hooksArray.prototype.findLastIndexMapeventDispatcherbuffers
1.0.0

12 days ago