rino0601 commented on issue #23796:
URL: https://github.com/apache/airflow/issues/23796#issuecomment-1154638740

   @uranusjr  Seems to need more explain about PR, let me supplement that.
   
   [In the comment 
above](https://github.com/apache/airflow/issues/23796#issuecomment-1149846840), 
I found a way to do it only with configuration, so I used `time.gmtime` to 
always output utc regardless of the system settings. The reason I had to do 
that was because the regular expression of UI could not be changed with 
configuration .
   
   While writing [PR](https://github.com/apache/airflow/pull/24373) , I was 
also able to edit the UI regex, so I didn't have to lock the log to UTC, so I 
didn't use `time.gmtime` (to allow users to get log files that use server 
timezone ).
   
   Instead, I override the `default_time_format` to append `%z` to the 
`%(asctime)s` output of the log file. Also, in python 3.7 and 3.8, 
`default_msec_format` cannot be omitted, so I set it to an appropriate value so 
that it does not interfere with the regular expression of the UI.
   
   Thankfully `moments.js` can handle both `+00:00` and `+0000`(python %z 
style)  properly. 
   > 
![Moment_js_Sandbox_-_JSFiddle_-_Code_Playground](https://user-images.githubusercontent.com/1422445/173479909-3b2d7df2-a764-4073-9720-61fedd88d5aa.png)
   > https://jsfiddle.net/wbqs84x3/
   
   Since we are already using `moments.js` in `updateAllDateTimes` at 
`www/static/js/datetime_utils.js`, 
   
   
https://github.com/apache/airflow/blob/fe2ef0fcc75fa7be9e1ec1113af260a3a3c9e7ae/airflow/www/static/js/datetime_utils.js#L79
   
   all I have to do is pass in a datetime string that `moments.js` can 
recognize. This was achieved by fixing the regex in `www/static/js/ti_log.js`
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to