victor-dev-toolbox
Advanced tools
Comparing version 1.2.92 to 1.2.93
@@ -729,2 +729,15 @@ interface CountryInterface { | ||
declare function dayMonthYear(date?: string | Date): string; | ||
/** | ||
* Formats a date or time as a string. | ||
* | ||
* @param date - The date or time to format, or `undefined` to use the current date and time. | ||
* @param options - Optional options to control the format of the output. | ||
* @param options.fullDate - If `true`, the output will include the full date and time. If `false`, only the time will be included. | ||
* @param options.format24 - If `true`, the time will be formatted in 24-hour format. If `false`, the time will be formatted in 12-hour format with AM/PM. | ||
* @returns The formatted date and/or time as a string. | ||
*/ | ||
declare function getTimeFromDate(date?: string | Date, options?: { | ||
fullDate?: boolean; | ||
format24?: boolean; | ||
}): string; | ||
@@ -1086,2 +1099,2 @@ interface UserRolesInterface { | ||
export { type API_NotificationInterface, type API_ResponseInterface, type AccountOwnerInterface, type AddRecordInterface, type AgeInterface, type BankAccountInterface, type BankAccountTypes, type BankBranchInterface, type BankInterface, type ChatDetailsInterface, type ChatInterface, type ChatMessageInterface, type ChatParticipantsInterface, type CountryInterface, type CurrencyConversionInterface, type CurrencyInterface, type DBStatusTypes, type DatabaseItemInterface, type DateRangeInterface, type DeleteOptionsInterface, DeliveryMethodsData, type DescriptionInterface, type DivisibleRangeInterface, type DivisibleRangeNumbersInterface, EastAfricanCountries, type FieldValueInterface, type FileUploadInterface, type FileUploadProgressInterface, type GooglePayTransactionInterface, type ImagePreviewTypes, type ImageShapeTypes, type ImageSizeTypes, type KenyaCountyInterface, type KeyValuePairInterface, type LocationInterface, type LoginInterface, type MultipleFieldValueInterface, type MultipleQueryInterface, type NotificationDataInterface, type NotificationInterface, type NotificationMessageInterface, type NotificationTypes, PRIVACY_POLICY_DATA, type PrivacyItemsInterface, type PrivacyPolicyInterface, type ResetPasswordInterface, type SignupInterface, TW_container, TW_iconButton, TW_justifyBetween, TW_justifyCenter, TW_responsiveGrid, TW_setColorBasedOnDarkMode, TimeGroupEnum, type UserNotificationInterface, type UserRoleTypes, type VideoThumbNailInterface, WordCount, allConditionsAreFalse, allConditionsAreTrue, assignDefaltValuesToUndefinedFields, checkIfItemExistsInArray, checkProductAvailability, checkThatObjectFieldMatchesSpecifiedValue, combineArrays, continentData, convertFromCamelCaseToSentenceCase, convertFromSentenceToCamelCase, convertToSpecifiedCurrency, copyToClipboard, countriesData, createAPINotification, createObject, createTimeGroup, dayMonthYear, defaultCurrencyData, defaultLandingPage, downloadImageFromUrl, enableUpdate, filterArrayBySpecifiedField, filterByDateRange, filterByNestedArrayValue, filterFieldsFromArray, filterItemsByField, filterItemsByFieldValues, findAllNumbersDivisibleBySpecifiedDigit, generateFields, generateQRCode, generateRandomNumber, generateRandomString, generateSearchFields, generateUniqueId, getAgeFromDateString, getCurrentTime, getDataFromAPiResponse, getDayOfTheWeek, getDayOftheWeekFromDate, getDigitsFromNumber, getEnumValues, getFieldValuesFromArray, getFirstDayOfTheMonthUntilToday, getFirstWords, getFullAge, getFullDateToday, getImageURLfromArray, getItemFromArrayByIndex, getItemsCreatedOnSpecifiedDay, getItemsCreatedToday, getItemsWithinDateRange, getLastWordsInRange, getMidnightDate, getMilisecondsTillMidnight, getObjectPartialsFromArray, getPastDates, getPrivacyPolicy, getRangeForSpecifiedDate, getTimeAgo, getTimeDifference, getTimeGroup, getTotalForField, getXDaysFromTomorrow, getfieldFromTimeGroup, groupItemsByfield, hasNullOrUndefinedFields, isToday, isUserAuthorizedToUpdateItem, isValidDate, isWithinSpecifiedDay, jumpToXNumberOfDays, kenyaCounties, locationsData, mergeObjects, noConditionIsFalse, noConditionIsTrue, onImageSelected, openEmail, openPhone, openWhatsapp, prepareApiResponse, prepareFileUploads, productAvailabilityData, productsToHideData, removeDuplicatesByKeys, resolveMultiplePromises, resolveMultiplePromisesInIntervals, routesNotToSaveData, searchObjectsByFields, selectCountryPage, shareItem, type shareItemInterface, shuffleArray, sortArrayByKey, testDivisibilityBySpecifiedDigit, timeStampHasExpired, toFixedDecimalPlaces, unauthorizedPage, uniqueArrayItems, upsertItemInArray, validateUniqueId, wasItemCreatedByUser }; | ||
export { type API_NotificationInterface, type API_ResponseInterface, type AccountOwnerInterface, type AddRecordInterface, type AgeInterface, type BankAccountInterface, type BankAccountTypes, type BankBranchInterface, type BankInterface, type ChatDetailsInterface, type ChatInterface, type ChatMessageInterface, type ChatParticipantsInterface, type CountryInterface, type CurrencyConversionInterface, type CurrencyInterface, type DBStatusTypes, type DatabaseItemInterface, type DateRangeInterface, type DeleteOptionsInterface, DeliveryMethodsData, type DescriptionInterface, type DivisibleRangeInterface, type DivisibleRangeNumbersInterface, EastAfricanCountries, type FieldValueInterface, type FileUploadInterface, type FileUploadProgressInterface, type GooglePayTransactionInterface, type ImagePreviewTypes, type ImageShapeTypes, type ImageSizeTypes, type KenyaCountyInterface, type KeyValuePairInterface, type LocationInterface, type LoginInterface, type MultipleFieldValueInterface, type MultipleQueryInterface, type NotificationDataInterface, type NotificationInterface, type NotificationMessageInterface, type NotificationTypes, PRIVACY_POLICY_DATA, type PrivacyItemsInterface, type PrivacyPolicyInterface, type ResetPasswordInterface, type SignupInterface, TW_container, TW_iconButton, TW_justifyBetween, TW_justifyCenter, TW_responsiveGrid, TW_setColorBasedOnDarkMode, TimeGroupEnum, type UserNotificationInterface, type UserRoleTypes, type VideoThumbNailInterface, WordCount, allConditionsAreFalse, allConditionsAreTrue, assignDefaltValuesToUndefinedFields, checkIfItemExistsInArray, checkProductAvailability, checkThatObjectFieldMatchesSpecifiedValue, combineArrays, continentData, convertFromCamelCaseToSentenceCase, convertFromSentenceToCamelCase, convertToSpecifiedCurrency, copyToClipboard, countriesData, createAPINotification, createObject, createTimeGroup, dayMonthYear, defaultCurrencyData, defaultLandingPage, downloadImageFromUrl, enableUpdate, filterArrayBySpecifiedField, filterByDateRange, filterByNestedArrayValue, filterFieldsFromArray, filterItemsByField, filterItemsByFieldValues, findAllNumbersDivisibleBySpecifiedDigit, generateFields, generateQRCode, generateRandomNumber, generateRandomString, generateSearchFields, generateUniqueId, getAgeFromDateString, getCurrentTime, getDataFromAPiResponse, getDayOfTheWeek, getDayOftheWeekFromDate, getDigitsFromNumber, getEnumValues, getFieldValuesFromArray, getFirstDayOfTheMonthUntilToday, getFirstWords, getFullAge, getFullDateToday, getImageURLfromArray, getItemFromArrayByIndex, getItemsCreatedOnSpecifiedDay, getItemsCreatedToday, getItemsWithinDateRange, getLastWordsInRange, getMidnightDate, getMilisecondsTillMidnight, getObjectPartialsFromArray, getPastDates, getPrivacyPolicy, getRangeForSpecifiedDate, getTimeAgo, getTimeDifference, getTimeFromDate, getTimeGroup, getTotalForField, getXDaysFromTomorrow, getfieldFromTimeGroup, groupItemsByfield, hasNullOrUndefinedFields, isToday, isUserAuthorizedToUpdateItem, isValidDate, isWithinSpecifiedDay, jumpToXNumberOfDays, kenyaCounties, locationsData, mergeObjects, noConditionIsFalse, noConditionIsTrue, onImageSelected, openEmail, openPhone, openWhatsapp, prepareApiResponse, prepareFileUploads, productAvailabilityData, productsToHideData, removeDuplicatesByKeys, resolveMultiplePromises, resolveMultiplePromisesInIntervals, routesNotToSaveData, searchObjectsByFields, selectCountryPage, shareItem, type shareItemInterface, shuffleArray, sortArrayByKey, testDivisibilityBySpecifiedDigit, timeStampHasExpired, toFixedDecimalPlaces, unauthorizedPage, uniqueArrayItems, upsertItemInArray, validateUniqueId, wasItemCreatedByUser }; |
{ | ||
"name": "victor-dev-toolbox", | ||
"version": "1.2.92", | ||
"version": "1.2.93", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -466,1 +466,38 @@ import { AgeInterface, DateRangeInterface, TimeGroupEnum } from "../interfaces/date-time.interface"; | ||
} | ||
/** | ||
* Formats a date or time as a string. | ||
* | ||
* @param date - The date or time to format, or `undefined` to use the current date and time. | ||
* @param options - Optional options to control the format of the output. | ||
* @param options.fullDate - If `true`, the output will include the full date and time. If `false`, only the time will be included. | ||
* @param options.format24 - If `true`, the time will be formatted in 24-hour format. If `false`, the time will be formatted in 12-hour format with AM/PM. | ||
* @returns The formatted date and/or time as a string. | ||
*/ | ||
export function getTimeFromDate(date?: string | Date, options?: { fullDate?: boolean; format24?: boolean }): string { | ||
const d = new Date(date || new Date()); | ||
const hours = d.getHours(); | ||
const minutes = d.getMinutes().toString().padStart(2, "0"); | ||
let timeString: string; | ||
if (options?.format24) { | ||
timeString = `${hours}:${minutes}`; | ||
} else { | ||
const period = hours >= 12 ? "PM" : "AM"; | ||
const hour12 = hours % 12 || 12; | ||
timeString = `${hour12}:${minutes} ${period}`; | ||
} | ||
if (options?.fullDate) { | ||
const day = d.getDate(); | ||
const month = d.toLocaleString("default", { month: "short" }); // Ex: Jan, Feb | ||
const year = d.getFullYear(); | ||
return `${month} ${day}, ${year} - ${timeString}`; | ||
} | ||
return timeString; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
479961
10064