[GH-ISSUE #1944] HAR Export on 12h Time Produces Incorrect Timestamps #1934

Closed
opened 2026-03-03 19:55:34 +03:00 by kerem · 10 comments
Owner

Originally created by @SimonRice on GitHub (Feb 22, 2024).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1944

Originally assigned to: @NghiaTranUIT on GitHub.

Description

It seems like that if I have my time format set to 12h & I export an HAR file between 1AM & 10AM or between 1PM & 10PM, the timestamps are incorrectly formatted, missing a leading 0 in the hour component.

As a result, the file can't be opened with Charles Proxy, and possibly other apps. Interestingly, Proxyman can still read the file correctly!

Steps to Reproduce

  1. Set your time format to 12 hour & ensure your time is either between 1AM & 10AM or between 1PM & 10PM.
  2. Record your session.
  3. Right click under "Apps" and go to Export -> as HAR (HTTP Archive). Save your file accordingly.
  4. Attempt to open your HAR file with Charles Proxy.

I do have an HAR file of a couple of Google request-response pairs I made with Proxyman that you're also welcome to use.

Current Behavior

The resulting HAR file imports in to Charles Proxy correctly.

Expected Behavior

The resulting HAR file fails to import in to Charles Proxy. It shows there's an issue with the timestamp(s).

Screenshot

Manually editing the timestamps via search/replace makes the file compatible with Charles Proxy again.

Environment

  • App version: Proxyman v5.0.0 (50000)
  • macOS version: macOS Sonoma v14.3.1
Originally created by @SimonRice on GitHub (Feb 22, 2024). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1944 Originally assigned to: @NghiaTranUIT on GitHub. ## Description It seems like that if I have my time format set to 12h & I export an HAR file between 1AM & 10AM or between 1PM & 10PM, the timestamps are incorrectly formatted, missing a leading `0` in the hour component. As a result, the file can't be opened with Charles Proxy, and possibly other apps. Interestingly, Proxyman can still read the file correctly! ## Steps to Reproduce 1. Set your time format to 12 hour & ensure your time is either between 1AM & 10AM or between 1PM & 10PM. 2. Record your session. 3. Right click under "Apps" and go to Export -> as HAR (HTTP Archive). Save your file accordingly. 4. Attempt to open your HAR file with Charles Proxy. [I do have an HAR file of a couple of Google request-response pairs I made with Proxyman that you're also welcome to use.](https://github.com/ProxymanApp/Proxyman/files/14372009/Apps_02-22-2024-09-34-07.har.zip) ## Current Behavior The resulting HAR file imports in to Charles Proxy correctly. ## Expected Behavior The resulting HAR file fails to import in to Charles Proxy. It shows there's an issue with the timestamp(s). <img width="891" alt="Screenshot" src="https://github.com/ProxymanApp/Proxyman/assets/548577/dba9807f-796a-430b-8d8a-26293d6882b8"> Manually editing the timestamps via search/replace makes the file compatible with Charles Proxy again. ## Environment - App version: Proxyman v5.0.0 (50000) - macOS version: macOS Sonoma v14.3.1
kerem 2026-03-03 19:55:34 +03:00
Author
Owner

@NghiaTranUIT commented on GitHub (Feb 23, 2024):

Thanks @SimonRice , let me fix it 👍

<!-- gh-comment-id:1960746129 --> @NghiaTranUIT commented on GitHub (Feb 23, 2024): Thanks @SimonRice , let me fix it 👍
Author
Owner

@NghiaTranUIT commented on GitHub (Feb 28, 2024):

@SimonRice it's odd that I can't reproduce it 🤔

Currently, Proxyman uses this format yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ to generate the startedDateTime

You can find this HAR Log:
Apps_02-28-2024-14-23-00.har.zip

The startedDateTime format is correct and it doesn't affect by the Use 12h format Option in the Setting.

"startedDateTime": "2024-02-28T14:22:54.786+07:00",

Can I ask if this bug still happen if you use 24h mode ?

<!-- gh-comment-id:1968386477 --> @NghiaTranUIT commented on GitHub (Feb 28, 2024): @SimonRice it's odd that I can't reproduce it 🤔 Currently, Proxyman uses this format `yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ` to generate the `startedDateTime` You can find this HAR Log: [Apps_02-28-2024-14-23-00.har.zip](https://github.com/ProxymanApp/Proxyman/files/14430221/Apps_02-28-2024-14-23-00.har.zip) The `startedDateTime` format is correct and it doesn't affect by the `Use 12h format` Option in the Setting. ``` "startedDateTime": "2024-02-28T14:22:54.786+07:00", ``` ---------------- Can I ask if this bug still happen if you use `24h mode` ?
Author
Owner

@NghiaTranUIT commented on GitHub (Feb 28, 2024):

even though I force the UK timezone in the TimeFormatter, it still has the leading 0

    static let iso8601: DateFormatter = {
        let formatter = DateFormatter()
        formatter.calendar = Calendar(identifier: .iso8601)
        formatter.locale = Locale(identifier: "en_GB")
        formatter.timeZone = TimeZone(identifier: "Europe/London")
        formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" // there is second decimal
        return formatter
    }()

HAR:

"startedDateTime": "2024-02-28T07:36:33.960Z",
<!-- gh-comment-id:1968396949 --> @NghiaTranUIT commented on GitHub (Feb 28, 2024): even though I force the UK timezone in the TimeFormatter, it still has the leading `0` ```swift static let iso8601: DateFormatter = { let formatter = DateFormatter() formatter.calendar = Calendar(identifier: .iso8601) formatter.locale = Locale(identifier: "en_GB") formatter.timeZone = TimeZone(identifier: "Europe/London") formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" // there is second decimal return formatter }() ``` HAR: ``` "startedDateTime": "2024-02-28T07:36:33.960Z", ```
Author
Owner

@SimonRice commented on GitHub (Feb 28, 2024):

Hi @NghiaTranUIT,

First of all, thank you so much for the reply.

I tried the above for a command line app, based on what you gave me:

import Foundation

let iso8601: DateFormatter = {
    let formatter = DateFormatter()
    formatter.calendar = Calendar(identifier: .iso8601)
    formatter.locale = Locale(identifier: "en_GB")
    formatter.timeZone = TimeZone(identifier: "Europe/London")
    formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" // there is second decimal
    return formatter
}()

let date = Date(timeIntervalSince1970: 1709106415) // Roughly 7:47 AM GMT on 2022-02-28

print(iso8601.string(from: date))

With this sample, it does print out 2024-02-28T07:46:55.000Z.

However, if I leave / comment out formatter.locale = Locale(identifier: "en_GB") it does not print out correctly - this prints out 2024-02-28T7:46:55.000Z.

Bizarrely, if I print out the formatter's locale's identifier within the body of iso8601 without setting the formatter's locale, I get en_GB@calendar=iso8601. Whereas with the formatter's locale set, that's understandably en_GB. I do wonder if using en_US_POSIX will do the trick here!

If it helps at all, I've attached my date & time and language & region settings here.

Screenshot 2024-02-28 at 7 42 49 am Screenshot 2024-02-28 at 7 52 27 am

Finally, if I do set my time setting to 24h, I do get a leading zero with your above sample and with the local setting commented out.

I hope this all helps.

<!-- gh-comment-id:1968418345 --> @SimonRice commented on GitHub (Feb 28, 2024): Hi @NghiaTranUIT, First of all, thank you so much for the reply. I tried the above for a command line app, based on what you gave me: ```swift import Foundation let iso8601: DateFormatter = { let formatter = DateFormatter() formatter.calendar = Calendar(identifier: .iso8601) formatter.locale = Locale(identifier: "en_GB") formatter.timeZone = TimeZone(identifier: "Europe/London") formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" // there is second decimal return formatter }() let date = Date(timeIntervalSince1970: 1709106415) // Roughly 7:47 AM GMT on 2022-02-28 print(iso8601.string(from: date)) ``` With this sample, it does print out `2024-02-28T07:46:55.000Z`. However, if I leave / comment out `formatter.locale = Locale(identifier: "en_GB")` it does not print out correctly - this prints out `2024-02-28T7:46:55.000Z`. Bizarrely, if I print out the formatter's locale's identifier within the body of `iso8601` without setting the formatter's locale, I get `en_GB@calendar=iso8601`. Whereas with the formatter's locale set, that's understandably `en_GB`. I do wonder if using `en_US_POSIX` will do the trick here! If it helps at all, I've attached my date & time and language & region settings here. <img width="827" alt="Screenshot 2024-02-28 at 7 42 49 am" src="https://github.com/ProxymanApp/Proxyman/assets/548577/90ddebb1-cba9-4aae-957b-dd6138945db3"> <img width="827" alt="Screenshot 2024-02-28 at 7 52 27 am" src="https://github.com/ProxymanApp/Proxyman/assets/548577/53eeb569-8a74-4fd4-ab3e-6095568e0417"> Finally, if I do set my time setting to 24h, I do get a leading zero with your above sample and with the local setting commented out. I hope this all helps.
Author
Owner

@NghiaTranUIT commented on GitHub (Feb 28, 2024):

Nice, I realize my original implementation is:

    static let iso8601: DateFormatter = {
        let formatter = DateFormatter()
        formatter.calendar = Calendar(identifier: .iso8601)
        formatter.locale = Locale.current
        formatter.timeZone = TimeZone.current
        formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" // there is second decimal
        return formatter
    }()

It means it somehow changes the behavior of the dateFormat string. Let me investigate it.


May I ask: Set your time format to 12 hour & ensure your time is either between 1AM & 10AM or between 1PM & 10PM.

Do you mean the 12 Format in Proxyman -> Setting -> Advance Tab -> Use 24h format ?

Or the System Time Format (Date & Time) ?

<!-- gh-comment-id:1968433952 --> @NghiaTranUIT commented on GitHub (Feb 28, 2024): Nice, I realize my original implementation is: ``` static let iso8601: DateFormatter = { let formatter = DateFormatter() formatter.calendar = Calendar(identifier: .iso8601) formatter.locale = Locale.current formatter.timeZone = TimeZone.current formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" // there is second decimal return formatter }() ``` It means it somehow changes the behavior of the `dateFormat` string. Let me investigate it. --------- May I ask: `Set your time format to 12 hour & ensure your time is either between 1AM & 10AM or between 1PM & 10PM.` Do you mean the 12 Format in Proxyman -> Setting -> Advance Tab -> Use 24h format ? Or the System Time Format (Date & Time) ?
Author
Owner

@SimonRice commented on GitHub (Feb 28, 2024):

May I ask: Set your time format to 12 hour & ensure your time is either between 1AM & 10AM or between 1PM & 10PM.

Do you mean the 12 Format in Proxyman -> Setting -> Advance Tab -> Use 24h format ?

Or the System Time Format (Date & Time) ?

I did mean system format - however, on Proxyman's advanced tab, it's switched off as well.

Screenshot 2024-02-28 at 8 09 38 am
<!-- gh-comment-id:1968438927 --> @SimonRice commented on GitHub (Feb 28, 2024): > May I ask: `Set your time format to 12 hour & ensure your time is either between 1AM & 10AM or between 1PM & 10PM.` > > Do you mean the 12 Format in Proxyman -> Setting -> Advance Tab -> Use 24h format ? > > Or the System Time Format (Date & Time) ? I did mean system format - however, on Proxyman's advanced tab, it's switched off as well. <img width="713" alt="Screenshot 2024-02-28 at 8 09 38 am" src="https://github.com/ProxymanApp/Proxyman/assets/548577/0dd18366-5065-4d01-b04e-d075e5008708">
Author
Owner

@NghiaTranUIT commented on GitHub (Feb 29, 2024):

@SimonRice can you try this build: https://download.proxyman.io/beta/Proxyman_5.0.0_Try_to_fix_the_ISO_8601.dmg

I use ISO8601DateFormatter rather than DateFormatter with a custom dateString. ISO8601DateFormatter doesn't allow to have the time zone, it always use UTC and we should not override with current timezone or locale.

I test and it works on my end 👍

<!-- gh-comment-id:1970182691 --> @NghiaTranUIT commented on GitHub (Feb 29, 2024): @SimonRice can you try this build: https://download.proxyman.io/beta/Proxyman_5.0.0_Try_to_fix_the_ISO_8601.dmg I use `ISO8601DateFormatter` rather than DateFormatter with a custom dateString. `ISO8601DateFormatter` doesn't allow to have the time zone, it always use UTC and we should not override with current timezone or locale. I test and it works on my end 👍
Author
Owner

@SimonRice commented on GitHub (Feb 29, 2024):

Thank you so much for this @NghiaTranUIT - this works perfectly 🎉

<!-- gh-comment-id:1970580691 --> @SimonRice commented on GitHub (Feb 29, 2024): Thank you so much for this @NghiaTranUIT - this works perfectly 🎉
Author
Owner

@NghiaTranUIT commented on GitHub (Mar 1, 2024):

Awesome 👍

<!-- gh-comment-id:1972371675 --> @NghiaTranUIT commented on GitHub (Mar 1, 2024): Awesome 👍
Author
Owner

@SimonRice commented on GitHub (Apr 23, 2024):

The amend in question is still working brilliantly 🎉 I've been meaning to close this issue for ages, so I'll do that now! Thank you @NghiaTranUIT once again for your brilliant support!

<!-- gh-comment-id:2072039422 --> @SimonRice commented on GitHub (Apr 23, 2024): The amend in question is still working brilliantly 🎉 I've been meaning to close this issue for ages, so I'll do that now! Thank you @NghiaTranUIT once again for your brilliant support!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Proxyman#1934
No description provided.