From 83c32d7deb49c06a10fbbf90e701041fffdeb6d1 Mon Sep 17 00:00:00 2001 From: Mike Brown Date: Fri, 17 Nov 2023 16:38:53 +0000 Subject: [PATCH] Avoid time.DateOnly It looks like the github action build environment for this repo uses a go 1.19.x environment which does not have time.DateOnly. Replace with local constant until this is upgraded. --- billing.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/billing.go b/billing.go index 33f3ce9bf..d98087088 100644 --- a/billing.go +++ b/billing.go @@ -31,6 +31,10 @@ type BillingUsageResponse struct { httpHeader } +// @todo remove this and replace w/ time.DateOnly once github build +// environment is upgraded to a more recent go toolchain. +const DateOnly = "2006-01-02" + // currently the OpenAI usage API is not publicly documented and will explictly // reject requests using an API key authorization. however, it can be utilized // logging into https://platform.openai.com/usage and retrieving your session @@ -43,8 +47,8 @@ var ( // GetBillingUsage — API call to Get billing usage details. func (c *Client) GetBillingUsage(ctx context.Context, startDate time.Time, endDate time.Time) (response BillingUsageResponse, err error) { - startDateArg := fmt.Sprintf("start_date=%v", startDate.Format(time.DateOnly)) - endDateArg := fmt.Sprintf("end_date=%v", endDate.Format(time.DateOnly)) + startDateArg := fmt.Sprintf("start_date=%v", startDate.Format(DateOnly)) + endDateArg := fmt.Sprintf("end_date=%v", endDate.Format(DateOnly)) queryParams := fmt.Sprintf("%v&%v", startDateArg, endDateArg) urlSuffix := fmt.Sprintf("%v?%v", billingUsageSuffix, queryParams)