#51 Use datetime for getting current date
Merged 7 years ago by lsedlar. Opened 7 years ago by lsedlar.
lsedlar/compose-utils time-tests  into  master

@@ -5,7 +5,7 @@ 

  import argparse

  import errno

  import os

- import time

+ from datetime import datetime

  

  import kobo.conf

  from productmd.composeinfo import ComposeInfo
@@ -35,7 +35,7 @@ 

  

      ci.compose.label = compose_label

      ci.compose.type = compose_type

-     ci.compose.date = compose_date or time.strftime("%Y%m%d", time.localtime())

+     ci.compose.date = compose_date or datetime.today().strftime("%Y%m%d")

      ci.compose.respin = compose_respin or 0

  

      while 1:

As opposed to time.locatime, this does not use system timezone when time is frozen in tests. The results should otherwise be identical.

Fixes: https://pagure.io/compose-utils/issue/47

Tested this change, and the tests pass now with my timezone. Thanks!

Pull-Request has been merged by lsedlar

7 years ago