abuzarAli commited on
Commit
03ef91d
·
verified ·
1 Parent(s): 214077f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -7,11 +7,17 @@ import json
7
  class Block:
8
  def __init__(self, index, timestamp, transactions, previous_hash):
9
  self.index = index
10
- self.timestamp = timestamp
11
  self.transactions = transactions
12
  self.previous_hash = previous_hash
13
  self.hash = self.calculate_hash()
14
 
 
 
 
 
 
 
15
  def calculate_hash(self):
16
  block_content = json.dumps({
17
  "index": self.index,
 
7
  class Block:
8
  def __init__(self, index, timestamp, transactions, previous_hash):
9
  self.index = index
10
+ self.timestamp = self.get_pakistan_time(timestamp)
11
  self.transactions = transactions
12
  self.previous_hash = previous_hash
13
  self.hash = self.calculate_hash()
14
 
15
+ def get_pakistan_time(self, utc_time):
16
+ """Convert UTC time to Pakistan Standard Time."""
17
+ pst_timezone = pytz.timezone("Asia/Karachi")
18
+ local_time = datetime.fromtimestamp(utc_time, pytz.utc).astimezone(pst_timezone)
19
+ return local_time.strftime("%a %b %d %H:%M:%S %Y") # Human-readable format
20
+
21
  def calculate_hash(self):
22
  block_content = json.dumps({
23
  "index": self.index,