Skip to content

Latest commit

 

History

History
47 lines (24 loc) · 1.77 KB

File metadata and controls

47 lines (24 loc) · 1.77 KB

Time Utilities

  • StartOfDay: Returns a time.Time set to the beginning (00:00:00) of the given day.

  • EndOfDay: Returns a time.Time set to the last moment (23:59:59.999999999) of the given day.

  • AddBusinessDays: Adds specified number of business days (excluding weekends) to a given date.

  • IsWeekend: Determines if a given date falls on a weekend (Saturday or Sunday).

  • TimeDifferenceHumanReadable: Converts time difference between two dates into a human-friendly string (e.g., "in 2 days" or "3 hours ago").

  • DurationUntilNext: Calculates duration until the next occurrence of a specific weekday.

  • ConvertToTimeZone: Converts a time.Time to a different timezone based on location name.

  • HumanReadableDuration: Formats a duration into a human-readable string (e.g., "2h 30m 45s").

  • CalculateAge: Computes age in years given a birth date.

  • IsLeapYear: Checks if a given year is a leap year.

  • NextOccurrence: Finds the next occurrence of a specific time on the same or next day.

  • WeekNumber: Returns the ISO year and week number for a given date.

  • DaysBetween: Calculates the number of days between two dates.

  • IsTimeBetween: Checks if a time falls between two other times.

  • UnixMilliToTime: Converts Unix milliseconds timestamp to time.Time.

  • SplitDuration: Breaks down a duration into days, hours, minutes, and seconds.

  • GetMonthName: Returns the English name of a month given its number (1-12).

  • GetDayName: Returns the English name of a day given its number (0-6).

  • FormatForDisplay: Formats a date in a readable format (e.g., "Monday, 2 Jan 2006").

  • IsToday: Checks if a given date is today.

Examples:

For examples of each function, please checkout EXAMPLES.md