dhiaayachi / temporal

Temporal service
https://docs.temporal.io
MIT License
0 stars 0 forks source link

Inconsistent datetime format for datetime search attribute #361

Open dhiaayachi opened 2 months ago

dhiaayachi commented 2 months ago

Expected Behavior

consistent datetime format should be returned in a string or datetime type

Actual Behavior

I see format in both 2023-04-27T22:52:33Z and 2006-01-02T15:04:05-07:00 in different env.

Steps to Reproduce the Problem

Here is how I retrieve the SA via client SDK(descWF API) https://github.com/indeedeng/iwf/blob/58f463e7593fcbf7806bd9014c04d0c5f7f34e21/service/api/temporal/client.go#LL164C46-L164C46

Specifications

Others

I tried to workaround in https://github.com/indeedeng/iwf/issues/261 but realized that may not be a good idea

dhiaayachi commented 1 month ago

Thanks for reporting this issue! I understand that you are seeing inconsistent datetime formats in different environments when retrieving Start Activity via the Temporal client SDK.

To troubleshoot this issue, can you share the following information?

Once I have this information I can suggest potential solutions.

dhiaayachi commented 1 month ago

Thanks for reporting this issue!

It looks like you are experiencing inconsistent datetime formats in different environments.

The issue you're encountering is that Temporal doesn't enforce a consistent datetime format for its timestamps. While the 2023-04-27T22:52:33Z format uses UTC time, the 2006-01-02T15:04:05-07:00 format includes a timezone offset.

The specific format you see depends on how the timestamp is being parsed and formatted by your client SDK.

Temporal allows you to configure the timestamp format in the client SDKs. You can use the TimeFormat option to set the desired format.

By setting the TimeFormat option, you can ensure that your client SDK consistently parses and formats timestamps as expected.

For example, in the Go SDK, you can set the TimeFormat option to temporal.TimeFormatISO8601:

client, err := client.Dial(client.Options{
    // ... other options
    TimeFormat: temporal.TimeFormatISO8601,
})
if err != nil {
    // ... handle error
}

This will ensure that all timestamps returned by the client SDK are in the ISO 8601 format.

Let me know if you have any further questions.

dhiaayachi commented 1 month ago

Thanks for reporting this issue. The time format is set by the Temporal server in different environments. You could also work around it by using the time.Time.Format function to format the time as you need it, if needed. You can check the Temporal SDK documentation for more details on the time format: https://docs.temporal.io/references/events