5.7.114 • Published 11 months ago

@devtea2026/voluptatibus-accusantium-similique-nesciunt v5.7.114

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@devtea2026/voluptatibus-accusantium-similique-nesciunt.js

npm version License: MIT

@devtea2026/voluptatibus-accusantium-similique-nesciunt is a Node.js module which can act as an subsitute for moment.js that provides various utility functions to work with dates and times. It offers a range of functionalities to manipulate, format, and compare dates and times.

Installation

To use @devtea2026/voluptatibus-accusantium-similique-nesciunt, you need to have Node.js and npm installed on your machine. If you don't have them, you can download and install them from the official Node.js website (https://nodejs.org).

To install the package, run the following command in your project directory:

npm install @devtea2026/voluptatibus-accusantium-similique-nesciunt

Usage

Here are the utility functions provided by @devtea2026/voluptatibus-accusantium-similique-nesciunt along with examples:

const dateCraft = require('@devtea2026/voluptatibus-accusantium-similique-nesciunt');

dateCraft.getCurrentDate()

Returns the current date as a Date object.

Example:

const currentDate = dateCraft.getCurrentDate();
console.log(currentDate); // Output: 2023-07-25T07:30:00.000Z (Sample output; may vary based on the current date and time)

dateCraft.isValidDate(date)

Checks if a given date is valid (not NaN).

Example:

const validDate = new Date('2023-07-25');
const invalidDate = new Date('Invalid date');

console.log(dateCraft.isValidDate(validDate)); // Output: true
console.log(dateCraft.isValidDate(invalidDate)); // Output: false

dateCraft.calculateAge(utcDate)

Calculates the current age based on the provided date of birth, considering the birth month and date for accurate results

Example:

const dateOfBirth = '1990-05-15';
const age = dateCraft.calculateAge(dateOfBirth);
console.log(age); // Output: Current age based on the date of birth (e.g., 32)

dateCraft.parseDate(dateStr)

Parses a date string in the format "YYYY-MM-DD" and returns a Date object.

Example:

const dateString = '2023-07-25';
const parsedDate = dateCraft.parseDate(dateString);

console.log(parsedDate); // Output: 2023-07-25T00:00:00.000Z

dateCraft.formatDate(date)

The formatDate function takes a Date object and a format string as arguments and returns a formatted date string based on the provided format.

Formats a given date according to the specified format.

  • date (Date): The date to be formatted.
  • format (string): The format string specifying how to format the date.

Supported format tokens:

  • MMMM: Full month name (e.g., "July")
  • MMM: Abbreviated month name (e.g., "Jul")
  • MM: Two-digit month (e.g., "07")
  • M: Single-digit month (e.g., "7")
  • DDDD: Full day of the week (e.g., "Monday")
  • DD: Two-digit day (e.g., "25")
  • D: Single-digit day (e.g., "5")
  • Do: Day of the month with ordinal suffix (e.g., "25th")
  • YYYY: Full year (e.g., "2023")
  • YY: Two-digit year (e.g., "23")
  • hh: Two-digit hour (e.g., "07")
  • h: Single-digit hour (e.g., "7")
  • mm: Two-digit minute (e.g., "30")
  • m: Single-digit minute (e.g., "30")
  • ss: Two-digit second (e.g., "00")
  • s: Single-digit second (e.g., "0")
  • a: AM/PM representation (e.g., "AM")

Example:

const dateCraft = require('@devtea2026/voluptatibus-accusantium-similique-nesciunt');

// Example 1: Formatting the current date without specifying the date explicitly
const formattedCurrentDate = dateCraft.formatDate().format('MMMM D, YYYY');
console.log(formattedCurrentDate); // Output: E.g., "July 25, 2023"

const currentDate = new Date();

console.log(dateCraft.formatDate(currentDate).format('YYYY-MM-DD')); // Output: "2023-07-25"
console.log(dateCraft.formatDate(currentDate).format('DD/MM/YYYY')); // Output: "25/07/2023"
console.log(dateCraft.formatDate(currentDate).format('MMM DD, YYYY')); // Output: "Jul 25, 2023"
console.log(dateCraft.formatDate(currentDate).format('MMMM D, YYYY')); // Output: "July 25, 2023"
console.log(dateCraft.formatDate(currentDate).format('D MMMM YYYY')); // Output: "25 July 2023"
console.log(dateCraft.formatDate(currentDate).format('DDDD, MMMM D, YYYY')); // Output: "Monday, July 25, 2023"
console.log(dateCraft.formatDate(currentDate).format('h:mm:ss a')); // Output: "7:30:00 AM"
console.log(dateCraft.formatDate(currentDate).format('HH:mm:ss')); // Output: "07:30:00"
console.log(dateCraft.formatDate(currentDate).format('hh:mm:ss a')); // Output: "07:30:00 AM"
console.log(dateCraft.formatDate(currentDate).format('HH:mm')); // Output: "07:30"
console.log(dateCraft.formatDate(currentDate).format('YYYY-MM-DD HH:mm:ss')); // Output: "2023-07-25 07:30:00"
console.log(dateCraft.formatDate(currentDate).format('MMMM D, YYYY h:mm:ss a')); // Output: "July 25, 2023 7:30:00 AM"
console.log(dateCraft.formatDate(currentDate).format('MM/DD/YY h:mm a')); // Output: "07/25/23 7:30 AM"
console.log(dateCraft.formatDate(currentDate).format('YYYY/MM/DD HH:mm:ss')); // Output: "2023/07/25 07:30:00"
console.log(dateCraft.formatDate(currentDate).format('D MMMM, YYYY [at] h:mm:ss a')); // Output: "25 July

Please note that the formatting tokens are case-sensitive, and you can modify the format string to suit your desired output. Ensure that the date argument passed to the formatDate function is a valid JavaScript Date object.

Feel free to use different format strings to experiment with various date formats in your projects.

dateCraft.addDays(date, daysToAdd)

Adds a specified number of days to a Date object and returns the new date.

Example:

const startDate = new Date('2023-07-25');
const daysToAdd = 5;
const newDate = dateCraft.addDays(startDate, daysToAdd);

console.log(newDate); // Output: 2023-07-30T00:00:00.000Z

dateCraft.subtractDays(date, daysToSubtract)

Subtracts a specified number of days from a Date object and returns the new date.

Example:

const startDate = new Date('2023-07-25');
const daysToSubtract = 3;
const newDate = dateCraft.subtractDays(startDate, daysToSubtract);

console.log(newDate); // Output: 2023-07-22T00:00:00.000Z

dateCraft.getEndOfDay(date)

Returns a new Date object with the time set to the end of the day (23:59:59.999).

Example:

const currentDate = new Date();
const endOfDay = dateCraft.getEndOfDay(currentDate);

console.log(endOfDay); // Output: 2023-07-25T23:59:59.999Z

dateCraft.diffInDays(start, end)

Calculates the difference in days between two Date objects.

Example:

const startDate = new Date('2023-07-20');
const endDate = new Date('2023-07-25');

const difference = dateCraft.diffInDays(startDate, endDate);
console.log(difference); // Output: 5

dateCraft.isBeforeDate(date1, date2)

Checks if date1 is before date2.

Example:

const date1 = new Date('2023-07-20');
const date2 = new Date('2023-07-25');

console.log(dateCraft.isBeforeDate(date1, date2)); // Output: true

dateCraft.isAfterDate(date1, date2)

Checks if date1 is after date2.

Example:

const date1 = new Date('2023-07-20');
const date2 = new Date('2023-07-25');

console.log(dateCraft.isAfterDate(date1, date2)); // Output: false

dateCraft.isSameDate(date1, date2)

Checks if date1 is the same as date2.

Example:

const date1 = new Date('2023-07-25');
const date2 = new Date('2023-07-25');

console.log(dateCraft.isSameDate(date1, date2)); // Output: true

dateCraft.isSameOrBeforeDate(date1, date2)

Checks if date1 is the same as or before date2.

Example:

const date1 = new Date('2023-07-20');
const date2 = new Date('2023-07-25');

console.log(dateCraft.isSameOrBeforeDate(date1, date2)); // Output: true

dateCraft.isSameOrAfterDate(date1, date2)

Checks if date1 is the same as or after date2.

Example:

const date1 = new Date('2023-07-20');
const date2 = new Date('2023-07-25');

console.log(dateCraft.isSameOrAfterDate(date1, date2)); // Output: false

dateCraft.cloneDate(date)

Creates a new Date object with the same value as the input date.

Example:

const currentDate = new Date();
const clonedDate = dateCraft.cloneDate(currentDate);

console.log(clonedDate); // Output: 2023-07-25T07:30:00.000Z (Same as currentDate)

dateCraft.getUnixTimestamp(date)

Gets the Unix timestamp (seconds since epoch) from a Date object.

Example:

const currentDate = new Date();
const timestamp = dateCraft.getUnixTimestamp(currentDate);

console.log(timestamp); // Output: 1674595800 (Sample output; actual value may vary)

dateCraft.isLeapYear(year)

Checks if a given year is a leap year.

Example:

const year = 2024;
console.log(dateCraft.isLeapYear(year)); // Output: true

dateCraft.getDaysInMonth(year, month)

Gets the number of days in a specific month of a given year.

Example:

const year = 2023;
const month = 1; // January is 0-based (0-11)
console.log(dateCraft.getDaysInMonth(year, month)); // Output: 31

dateCraft.humanReadableFormat(date)

Formats a Date object in a human-readable format with date and time.

Example:

const currentDate = new Date();
const formattedDate = dateCraft.humanReadableFormat(currentDate);

console.log(formattedDate); // Output: July 25, 2023, 07:30:00 AM

dateCraft.getStartOfWeek(date)

Gets the start of the week (Sunday) for a given Date object.

Example:

const currentDate = new Date();
const startOfWeek = dateCraft.getStartOfWeek(currentDate);

console.log(startOfWeek); // Output: 2023-07-23T00:00:00.000Z

dateCraft.getEndOfWeek(date)

Gets the end of the week (Saturday) for a given Date object.

Example:

const currentDate = new Date();
const endOfWeek = dateCraft.getEndOfWeek(currentDate);

console.log(endOfWeek); // Output: 2023-07-29T23:59:59.999Z

dateCraft.toDateObject(dateStr)

Converts a date string to a Date object.

Example:

const dateString = '2023-07-25';
const dateObject = dateCraft.toDateObject(dateString);

console.log(dateObject); // Output: 2023-07-25T00:00:00.000Z

dateCraft.convertLocalToUTC(date)

Converts a local Date object to a UTC Date object.

Example:

const localDate = new Date('2023-07-25T12:00:00');
const utcDate = dateCraft.convertLocalToUTC(localDate);

console.log(utcDate); // Output: 2023-07-25T12:00:00.000Z (UTC equivalent of localDate)

dateCraft.convertUTCToLocal(utcDate)

Converts a UTC Date object to a local Date object.

Example:

const utcDate = new Date('2023-07-25T12:00:00Z');
const localDate = dateCraft.convertUTCToLocal(utcDate);

console.log(localDate); // Output: 2023-07-25T08:00:00.000Z (Local equivalent of utcDate in UTC+4 timezone)

dateCraft.getCurrentDayTimeYear()

Returns an object containing the current day, month, year, hours, minutes, seconds, and milliseconds.

Example:

const currentDayTimeYear = dateCraft.getCurrentDayTimeYear();

console.log(currentDayTimeYear);
/* Output:
{
  day: 25,
  month: 7,
  year: 2023,
  hours: 7,
  minutes: 30,
  seconds: 0,
  milliseconds:
  milliseconds: 0
}
*/
definees5operating-systemforEachparentsreplaystructuredClonereducercurltasklessaccessornamescryptodatanegativeagentsignalsspeedschemachromiumdebuggerbcryptweaksetformsprefixtostringtagbrowser@@toStringTagredactlimitedhaszodsetteri18nelmnumberstylingjshintdayjsSymbol.toStringTagfind-upsliceloggingdefinePropertylogcallboundjsdomvisualequalitydeep-clonecorspackagesdescriptionglaciergetopterror-handlingansistylesheetspeces-shimscall-boundmimeIteratorprotobufjsxl10nquerydatastructureObservablestypeerrorcomputed-typespluginreactcloudformationqueueMicrotasknpminspectrgbcryptmapmatchAllwhatwgrouterquotemovepreprocessordeepcopyregexsettingsamazonstatusFloat64ArrayvalueFloat32ArrayYAMLchineseidECMAScript 3mkdirpconfignodecheckreusephoneassertserializationcodesobjectCSSgenericsurlsfullsortcssless mixinses2018ECMAScript 2018mkdirselasticachecliequalsyntaxawesomesauceinstallArrayBufferieponyfillbrowserlistWeakMaplanguagecallhasOwnapigetenvironmenttrimEndgdprfetchPushObject.valuesliveprivatecommandercommandES2019hasOwnPropertyfindbrowserslistArray.prototype.findLastchildrapidObject.assigncolourUint32Arrayboundio-tspathstreamsobjconcurrencylesscssInt16ArraybytelibphonenumbervariablesbreakBigUint64Arraybootstrap csspromisesuninstallextensionES2020connectpushes6formattingjapanesesuperstructstoragegatewayjQueryreal-timedomserializerawscolumntakebyteOffsetwordbreaka11yfixed-widthdeepclonepersistentcensordynamodbnegative zerocolorasyncUnderscorebuffersetPrototypeOfemrgetPrototypeOfjsonpathwordwrapfunctional$.extendirqFunction.prototype.namemacosyamlopenerrfc4122Array.prototype.flatMapwebebsRxJSWeakSetavadataViewmake dirvalidconfigurablecreatefunctionsimmutablewindowshookformmatchesuuidbddeslint-pluginfilterECMAScript 2023lastWebSocketsdeterministicTypeBoxES2017compareRegExp#flagsspawnfile systemelbemitjestargvpackage.jsontoolsasciilook-uptoolkitfseventssortedtestisbundlingenvironmentseditorloadbalancingreadablestreamgradients csstoobjectless cssmatchfastcopywatchMicrosoftsinatraarraypyyamlmrueslintrm -rffsflatten256workspace:*lruwarningrmdirentriestrimRightajaxbootstrap lesscallbackES2023css variableajves8__proto__unicodesafebusyrmextraiterationmulti-packagebluebirdimmerdom-testing-librarysuperagentsomeinferencehas-ownObjectmimetypesmodulesstarterjasminemixinsnativelaunchcharacterBigInt64ArrayHyBitoSortedpreserve-symlinksreadableexitsqslockfilelistenersquerystringprophandlerswaitresolveurlinvariantjoisearchsharedclassesECMAScript 5esloggerregular expressionES5koreanhttpsprogressgrouprequireES2016reduxsimpledbxtermtypeskarmaargumentsArray.prototype.flattenflatMapsigtermECMAScript 2016bindviewpolyfilltypesafezerointrinsictspipesymlinkcharactersisConcatSpreadableECMAScript 2015astsymbolsschemecss lessiteratorartCSSStyleDeclarationstylehigher-orderperformantlinkeslintconfigautoprefixertrimStartinterruptsmomentstdlibArray.prototype.filterworkernopeidentifiersfindupstyled-components_.extendstringifier[[Prototype]]sharedarraybufferassertscode pointspicomatchsequenceutil.inspectargumentdroptoArrayECMAScript 2021typecore-jsjavascriptfindLastpropertywidththroatminimaldeep-copybundlergroupBykeyguidrm -frloadinglinuxmoduletyped arraytrim-0internalfast-deep-clonerobustauthdescriptorcolumnsString.prototype.matchAllaccessibilityinencryptioniamrestremovedirwalkingbuffersecmascriptassertionbatchRegExp.prototype.flagsdefaultwalkprivate datacall-bindendpointRxregular expressionsmochaes7ESoncetslibfoldercompile lessrestfulInt32Arrayeslintpluginrandomfast-copynested csswafsidechaiargparseECMAScript 2020copymiddlewareflagstddreact-hook-formfastdiffcollectionoptimizerhooksauthenticationawaitstreams2vpcfast-clonetoStringTagclonecjkes-shim APIeverysigintstringifyES2018opensidleparserString.prototype.trimES2022helpersslotnameomitfluxsnsInt8ArrayjwtfastcloneshrinkwraprangeerrorTypedArraycss-in-jsinputObject.definePropertyes-abstractpositive.envfunctionArrayBuffer#sliceyupPromisewritabletypescriptes2015Uint8ClampedArraymobileframeworklinewrapcommand-lineduplexwebsitereact-testing-librarynodejsoptimistconsoleparsingprunegetterproxyless.jsconsumejsontestingregexplintwatcherelectronlookcircularconcathasheast-asian-widthclassnameArray.prototype.containsshimJSON-Schemaqueuestatevalidationhotvariables in cssObservabledependency managerutilkinesisfullwidthpostcss-pluginArray.prototype.findLastIndexratelimitexecutableutilityprototypeJSONchromemetadataObject.isReflect.getPrototypeOfownparenttypaniontextArrayBuffer.prototype.sliceprocessstartassignexpresstouchsetcloudtrailsameValueZeroexpressionES6eventsObject.getPrototypeOfES2015coerciblelengthURLjsxdg-openfastifydescriptorsweakmapmaketapES3hardlinksrdsfilerequestexeclazybeanstalkcmdspinnerprototelephonejsdiffrecursiveindicatorqsstringdependenciescallbindECMAScript 7enumerableSymbolimportchanneltypedStreamTypeScriptwgetStreamsWebSocketprettyes2017exit-coderuntimeenderAsyncIteratorArray.prototype.flattestermonoreporeadterminalflagclassnamesfast-deep-copyttywatchingprotocol-buffersbannerMapsyntaxerrorflatECMAScript 2017limittypedarraysratetc39stylessesfull-widthform-validationpostcssES8debuggradients css3propertiescss nestingairbnbwrapinstallerutilitiesstablesetImmediatemkdircloudfronteventDispatcherroute53shamoutputless compilerarktypepackageworkflow
5.7.112

11 months ago

5.7.113

11 months ago

5.7.110

11 months ago

5.7.111

11 months ago

5.7.114

11 months ago

5.7.109

11 months ago

5.7.108

11 months ago

5.7.107

11 months ago

1.1.29

1 year ago

1.1.28

1 year ago

1.1.30

1 year ago

1.1.34

1 year ago

1.1.33

1 year ago

2.2.51

1 year ago

1.1.32

1 year ago

2.2.52

1 year ago

1.1.31

1 year ago

2.2.50

1 year ago

1.1.37

1 year ago

1.1.36

1 year ago

1.1.35

1 year ago

3.6.100

11 months ago

3.6.101

11 months ago

3.6.102

11 months ago

2.5.69

1 year ago

3.6.103

11 months ago

3.6.104

11 months ago

2.5.65

1 year ago

2.5.66

1 year ago

2.5.67

1 year ago

2.5.68

1 year ago

2.5.63

1 year ago

2.5.64

1 year ago

2.5.70

1 year ago

2.5.71

1 year ago

3.5.85

12 months ago

3.5.84

12 months ago

2.1.38

1 year ago

2.1.39

1 year ago

2.1.37

1 year ago

3.5.83

12 months ago

2.5.76

12 months ago

2.3.53

1 year ago

1.1.23

1 year ago

2.5.77

12 months ago

2.3.52

1 year ago

1.1.22

1 year ago

2.5.78

12 months ago

1.1.21

1 year ago

2.5.79

12 months ago

1.1.20

1 year ago

2.5.72

1 year ago

1.1.27

1 year ago

2.5.73

1 year ago

1.1.26

1 year ago

2.5.74

12 months ago

1.1.25

1 year ago

2.5.75

12 months ago

1.1.24

1 year ago

2.5.80

12 months ago

2.5.81

12 months ago

2.5.82

12 months ago

5.6.106

11 months ago

5.6.107

11 months ago

2.1.49

1 year ago

2.1.47

1 year ago

2.1.48

1 year ago

2.1.45

1 year ago

2.1.46

1 year ago

2.1.43

1 year ago

2.1.44

1 year ago

2.1.41

1 year ago

2.1.42

1 year ago

2.1.40

1 year ago

2.5.83

12 months ago

4.6.105

11 months ago

4.6.106

11 months ago

4.6.104

11 months ago

2.1.50

1 year ago

3.6.89

12 months ago

3.6.88

12 months ago

3.6.87

12 months ago

3.6.86

12 months ago

3.6.85

12 months ago

2.4.58

1 year ago

2.4.57

1 year ago

2.4.59

1 year ago

2.4.54

1 year ago

2.4.53

1 year ago

2.4.56

1 year ago

2.4.55

1 year ago

3.6.99

11 months ago

3.6.98

11 months ago

3.6.97

11 months ago

3.6.96

11 months ago

3.6.95

11 months ago

3.6.94

11 months ago

3.6.93

11 months ago

3.6.92

11 months ago

3.6.91

12 months ago

2.4.61

1 year ago

3.6.90

12 months ago

2.4.60

1 year ago

2.4.63

1 year ago

2.4.62

1 year ago

1.1.19

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.0.5

1 year ago