package
0.0.0-20241018170054-3cebc5426995
Repository: https://github.com/phil-inc/pcommon.git
Documentation: pkg.go.dev
# Functions
No description provided by the author
AddStringValues adds 2 string formatted float numbers.
No description provided by the author
No description provided by the author
AddWorkingDays adds working days into the given date.
AdjustForHolidays checks if the provided date is a US holiday or a Sunday.
AdjustForWeekends checks if the provided date is a Saturday or Sunday.
ArePointerValuesEqual compares two pointers of any type, including *time.Time pointers.
B64Encode - encodes the given string with base 64.
No description provided by the author
BoolConfig returns config boolean value for the given key.
/ BusinessHourEndTime day end time for given time, hour and location.
BusinessHourEndTimeEST day end time for today.
BusinessHourStartTime day end time for given time, hour and location.
BusinessHourStartTimeEST day start time for today.
CastValue cast the given value into the given type.
No description provided by the author
CleanDoctorName clean up the doctor name to remove prefix and suffixes.
Cleans the input string by replacing all characters except alphanumeric characters, spaces, slashes, underscores, dashes, caret, @, plus, and dot with space, and remove multiple white spaces.
valid two factor code includes xxxxxx (6-digit code).
CleanUpEmail Clean up an email we receive in an API request.
No description provided by the author
Config returns string configuration for given key.
To check whether a string is included in the array or not.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ConvertStructSliceToMap converts slice to map.
ConvertStructToMap converts struct to map with value as interface.
ConvertStructToStringMap converts struct to map with value as string.
ConvertToPST converts the time to PST.
Gives regex pattern YYYY-MM-DD will give ^\d\d\d\d-\d\d-\d\d$.
ConvertUTCToPST converts UTC time to PST.
DayEndTime returns end date and time of specified time.
DateEndTimePST return the end date time for given date as PST.
DateStartTime returns start date and time of specified time.
DateStartTimePST return the start date time for given date as PST.
DayEndTime returns end date and time of the day.
DayEndTimeInTimeZoneLoc day end time in time zone location.
DayEndTimePST day end time PST.
DayEndTimePSTFor returns time based on year, month and day.
DaysBetween returns difference between two dates in days.
DayStartTime returns start date and time of the day.
DayStartTimeAtGivenDateHourPST day start time of given date PST.
DayStartTimeAtGivenHourPST day start time PST.
DayStartTimeEST day start time EST.
DayStartTimeInTimeZoneLoc day start time in time zone location.
DayStartTimePST day start time PST.
DayStartTimePSTFor returns time based on year, month and day.
No description provided by the author
DoesTwoSliceIntersect checks if a string slice contans at least one value of a given slice.
No description provided by the author
No description provided by the author
FirstName returns the first name only for the given full name.
No description provided by the author
No description provided by the author
FloatValue returns float64 value for a passed in value.
FormatDate formats the date to string using simple format yyyy-mm-dd.
FormatDateWithDayMonth returns the day of the week followed by mm/dd.
FormatDateWithTime formats the date to string using simple format yyyy-mm-dd h:mm a tz.
No description provided by the author
No description provided by the author
FormatOrderNumber formats the order number to xxxx-xxxx-xxxx.
FormatPhone formats the given phone number.
FormatPhoneToZendeskFormat formats the given phone number to: +1XXXXXXXXXX.
FormatPriceForDB formats the given currency as 2 decimal place USD only if it's decimal.
FormatPriceForDisplay formats the price in string format as 2 decimal value.
FormatSQLDate formats the date to the SQL date format that is RFC3339Nano.
Formats postgres returned date to specified date format.
No description provided by the author
FormatValidPhone formats the given phone number only if it's a valid phone number.
FortNightStartEndTimePST
returns previous month 2nd fortnight (1, last date) if given date is between 1 -15
else returns 1 -15 of this month
*/.
ForwardAdjustForWeekends checks if the provided date is a Saturday or Sunday.
GenerateRandomBytes returns securely generated random bytes.
GenerateRandomString returns a URL-safe, base64 encoded securely generated random string.
GetDateInStringPST converts the time to PST and formats to local date format.
Remove sensitive information.
GetDistinctFromStringSlice removes duplicate values from slice.
No description provided by the author
GetFirstWordsFromString returns the value of the first (count) number of words from a given string.
GetFormattedDateFromString converts a date string in the format "MM/DD/YYYY" or "MM/DD/YY" to a *time.Time.
GetFormattedDateWithoutYearByState formats a given time according to the state's timezone.
GetFormattedLocalTimeByState returns the formatted local time based on state.
No description provided by the author
GetHeaderValue retrieves the first value of the specified header key from *http.Request.
GetInteger return the integer part of a number.
GetLocDateFromState gets the time based on the given state's timezone if state is not found, default is CST TimeZone Parameter state should be in abbreviation form.
GetMaskedEmail replace middle charaters of email address with 3 asterik(***).
GetMaskedName replace last name with *****.
GetMaskedPhone returns last 4 digits of phone number.
GetNextWorkingDay returns the next working date from the given date.
No description provided by the author
GetPreviousWorkingDay returns the previous working date from the given date.
GetRegexFromDateString takes a date string as input and identifies its format using regular expressions.
GetRemoteIP retrieves the real IP address of the client from *http.Request It checks the "X-Forwarded-For" and "X-Real-Ip" headers and returns the first public IP found.
GetStartOfTheWeek returns the time for start of the current week.
Get state abbreviation from full name.
No description provided by the author
GetStringValueFromMap fetches value as dtring for the given key.
No description provided by the author
GetTimeInStringPST converts the time to PST and formats to local format with time.
GetUserLocationDetailsUsingIP fetches location data for the provided IP address using ipstack.
GetWorkingDaysBetween calculates the number of working days between two time points, 's' and 'd'.
HandleRefLoadError wraps all the given errors.
HasMatchingTimeZone returns true if job's trigger timezone matches user timezone.
HumanDate returns human readable date.
Include check if string is in an array.
Index returns index for a given string in an array of string.
IntConfig returns config integer value for the given key.
IsAfter checks if the provided date is after a specified time of day.
IsAfterDate returns true if date1 is after date2 otherwise returns false.
IsAlphanumeric checks if the string is alphanumeric.
IsBefore checks if the provided date is before a specified time of day.
IsAfterDate returns true if date1 is before date2 otherwise returns false.
IsBinValid validates bin
The criterias checked are:
1.
IsClosed checks if passed in channel is closed.
matches following date format YYYY-MM-DD MM-DD-YYYY YYYY/MM/DD MM/DD/YYYY YYYY.MM.DD MM.DD.YYYY.
IsDateTodayPST - checks whether the time stamp is today in PST time zone.
IsDebugMode check if app is running in debug mode.
IsDev returns if the application is running in dev environment.
Check if email is valid or not.
IsEqualSliceString compares if two slice has same string velues.
IsFeatureEnvironment check if the app is running inside a feature env.
No description provided by the author
No description provided by the author
IsInArray finds if given string is in array.
IsInsuranceIDValid check if the insurance ID is valid.
No description provided by the author
IsLocal checks if it's local environment.
No description provided by the author
IsMatchingLastName returns whether or not the last name provided matches the last name of the full name provided.
IsNextDay checks if the given time corresponds to the next day in the PST timezone.
ShouldStartOrderExport check if the order export is enabled.
IsPCNValid check if the pcn is valid.
IsPhoneNumber returns true if the given string matches phone number format.
IsProd check if application is running in prod env.
IsPureLocal checks if it's local environment.
IsReadOnlyMode check if application is running in read only mode.
IsRemotePublishEventsDisabled checks if publishing to remote events is enabled.
IsRemotePublishEventsDisabled checks if publishing to remote events is enabled.
IsRunningOnMinimalSeedDB check if the env is using minimal seed db (within feature env).
IsSameDate - compares year, month, day and checks to see if they are equal.
IsStage check if application is running in stage env.
IsSuffix check if the name is a suffix.
IsValidPassword validates password to have at least 8 character with number and alphabets.
IsWeekend checks if the date is in weekend.
No description provided by the author
IsWorkingDay checks if the given time falls on a working day.
LastDateOfYear return the last day of the year.
LastName returns the last name only for the given full name.
LoadTimeZoneLocation loads Location based on given timezone.
MergeStringSlices merges 'a' and 'b', excluding duplicates from 'b' already present in 'a'.
MiddleName returns the middle name only for the given full name.
MinutesBetween returns difference between two dates in minutes.
MonthStartEndTimePST start and end time for the given year and month in UTC.
MonthStartEndTimePST start and end time for the given year and month in PST.
Replace multiple spaces with a single space.
NowEST returns est time.
NowInTimeZoneLoc returns time in location.
NowPST returns local pacific time.
NowUTC returns current date time in UTC format.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ParseStringDOB - DOB in string format YYYY-MM-DD.
PartialName returns the full first name and first letter of the middle or last name.
No description provided by the author
RandomAlphabeticToken generates random string token comprised of only letters.
RandomDob generates a random dob between 18yr and 40yrs from current date.
RandomToken generates random string token.
RemoveSpaces removes all the spaces of a string.
RemoveUSDFormat.
SafeConfig returns empty string if the key doesn't exists.
No description provided by the author
SanitizeOrderNumber cleans up the order number.
SanitizePhoneNumber cleans up the phone number.
SanitizeStreetAddress cleans up street address.
SanitizeZip cleans up the zipcode.
SinceStartOfDayPST returns the start and end times of the current day in the PST timezone.
SinceStartOfMonthPST calculates the start and end times of the current month in the PST timezone.
SinceStartOfWeekPST calculates the start and end times of the current week in the PST timezone.
SnakeCase converts the given string to snake case.
Sort2DStringSliceByIndex sorts a 2D string slice based on the specified index.
StandardTimeZoneForState returns timezone for given state that maps to one of the 4 standard timezones we support.
StringArrayContains compares the value in dataset.
StringData fetch string data from events data map.
StringSliceContains checks if string slice contains given string.
StripSuffix Strip suffix returns an array of the input name separated by spaces and stripped of suffix.
SubtractStringValues subtracts v2 by v1.
SubtractWorkingDays subtracts working days into the given date.
TimeZoneForState returns timezone for given state.
Converts every first letter of the word in the sentence to uppercase.
ToEST converts the given UTC date to EST.
ToFixedPrecision Rounds the float to nearest like 12.3456 -> 12.35.
ToISODateTime converts a given time to its ISO 8601 representation.
ToJSON to JSON string.
ToPST converts the given UTC date to PST.
ToTimeZone converts the given UTC date to given time zone.
Trim trim the input string.
TrimAndLower trim the input string and also convert to lower case.
TrimAndTitle trim the input string and also convert to title case.
TrimAndUpper trim the input string and also convert to upper case.
Removes empty string from string slice.
TruncatedUSDFormat formats the given currency value to remove trailing ".00" if present.
TypeName returns the string value of the interface v.
No description provided by the author
No description provided by the author
USDFormat formats the given currency as 2 decimal place USD.
USFormatDate date in US format.
No description provided by the author
WithInTimeSpan checks if a given time 'check' falls within the time span defined by 'start' and 'end'.
WrapErrors wraps all the given errors.
YesNo change and return boolean to yes or no.
YesterdayPST returns local pacific time yesterday.
YesterdayStartEndTimePST start and end time for yesterday.
YYYYMMDDFormat formats a given time in YYYYMMDD format.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
mm/dd/yyyy.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
Empty empty string.
No description provided by the author
LocationEST location America/New_York.
LocationPST location America/Los_Angeles.
StartOfTheWeekMap day map for the week.
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author