Skip to content

Commit

Permalink
fix: DatePicker by passing in Timezone to API (#2770)
Browse files Browse the repository at this point in the history
* Fix DatePicker by passing in Timezone to API

* Add some clarity
  • Loading branch information
nalderto authored Jan 16, 2024
1 parent 5bcbbd4 commit 24bb3e0
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 124 deletions.
7 changes: 6 additions & 1 deletion api/v2/memo_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,14 @@ func (s *APIV2Service) GetUserMemosStats(ctx context.Context, request *apiv2pb.G
return nil, status.Errorf(codes.Internal, "failed to list memos")
}

location, err := time.LoadLocation(request.Timezone)
if err != nil {
return nil, status.Errorf(codes.Internal, "invalid timezone location")
}

creationStats := make(map[string]int32)
for _, memo := range memos {
creationStats[time.Unix(memo.CreatedTs, 0).Format("2006-01-02")]++
creationStats[time.Unix(memo.CreatedTs, 0).In(location).Format("2006-01-02")]++
}

response := &apiv2pb.GetUserMemosStatsResponse{
Expand Down
5 changes: 5 additions & 0 deletions proto/api/v2/memo_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ message GetUserMemosStatsRequest {
// name is the name of the user to get stats for.
// Format: users/{username}
string name = 1;

// timezone location
// Format: uses tz identifier
// https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
string timezone = 2;
}

message GetUserMemosStatsResponse {
Expand Down
1 change: 1 addition & 0 deletions proto/gen/api/v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1779,6 +1779,7 @@
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| name | [string](#string) | | name is the name of the user to get stats for. Format: users/{username} |
| timezone | [string](#string) | | timezone location Format: uses tz identifier https://en.wikipedia.org/wiki/List_of_tz_database_time_zones |



Expand Down
Loading

0 comments on commit 24bb3e0

Please sign in to comment.