Skip to content

Commit

Permalink
[bug] fix time calculation #143
Browse files Browse the repository at this point in the history
  • Loading branch information
alireza0 committed Apr 5, 2023
1 parent d0ce67a commit 38db94f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions web/assets/js/model/xray.js
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ Inbound.VmessSettings.Vmess = class extends XrayCommonClass {
return null;
}
if (this.expiryTime < 0){
return this.expiryTime / -84600000;
return this.expiryTime / -86400000;
}
return moment(this.expiryTime);
}
Expand Down Expand Up @@ -1551,7 +1551,7 @@ Inbound.VLESSSettings.VLESS = class extends XrayCommonClass {
return null;
}
if (this.expiryTime < 0){
return this.expiryTime / -84600000;
return this.expiryTime / -86400000;
}
return moment(this.expiryTime);
}
Expand Down Expand Up @@ -1685,7 +1685,7 @@ Inbound.TrojanSettings.Trojan = class extends XrayCommonClass {
return null;
}
if (this.expiryTime < 0){
return this.expiryTime / -84600000;
return this.expiryTime / -86400000;
}
return moment(this.expiryTime);
}
Expand Down
4 changes: 2 additions & 2 deletions web/html/xui/client_bulk_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@
return this.clientsBulkModal.inbound;
},
get delayedExpireDays() {
return this.clientsBulkModal.expiryTime < 0 ? this.clientsBulkModal.expiryTime / -84600000 : 0;
return this.clientsBulkModal.expiryTime < 0 ? this.clientsBulkModal.expiryTime / -86400000 : 0;
},
set delayedExpireDays(days){
this.clientsBulkModal.expiryTime = -84600000 * days;
this.clientsBulkModal.expiryTime = -86400000 * days;
},
},
});
Expand Down
4 changes: 2 additions & 2 deletions web/html/xui/client_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@
else return 'red'
},
get delayedExpireDays() {
return this.client && this.client.expiryTime < 0 ? this.client.expiryTime / -84600000 : 0;
return this.client && this.client.expiryTime < 0 ? this.client.expiryTime / -86400000 : 0;
},
set delayedExpireDays(days){
this.client.expiryTime = -84600000 * days;
this.client.expiryTime = -86400000 * days;
},
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion web/html/xui/inbound_info_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
[[ DateUtil.formatMillis(infoModal.clientSettings.expiryTime) ]]
</a-tag>
</template>
<a-tag v-else-if="infoModal.clientSettings.expiryTime < 0" color="cyan">[[ infoModal.clientSettings.expiryTime / -84600000 ]] {{ i18n "pages.client.days" }}</a-tag>
<a-tag v-else-if="infoModal.clientSettings.expiryTime < 0" color="cyan">[[ infoModal.clientSettings.expiryTime / -86400000 ]] {{ i18n "pages.client.days" }}</a-tag>
<a-tag v-else color="green">{{ i18n "indefinite" }}</a-tag>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion web/html/xui/inbounds.html
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@
if (!msg.success) {
return;
}
this.expireDiff = msg.obj.expireDiff * 84600000;
this.expireDiff = msg.obj.expireDiff * 86400000;
this.trafficDiff = msg.obj.trafficDiff * 1073741824;
},
setInbounds(dbInbounds) {
Expand Down
12 changes: 6 additions & 6 deletions web/service/tgbot.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func (t *Tgbot) getClientUsage(chatId int64, tgUserName string) {
if traffic.ExpiryTime == 0 {
expiryTime = "♾Unlimited"
} else if traffic.ExpiryTime < 0 {
expiryTime = fmt.Sprintf("%d days", traffic.ExpiryTime/-84600000)
expiryTime = fmt.Sprintf("%d days", traffic.ExpiryTime/-86400000)
} else {
expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05")
}
Expand Down Expand Up @@ -415,7 +415,7 @@ func (t *Tgbot) searchClient(chatId int64, email string) {
if traffic.ExpiryTime == 0 {
expiryTime = "♾Unlimited"
} else if traffic.ExpiryTime < 0 {
expiryTime = fmt.Sprintf("%d days", traffic.ExpiryTime/-84600000)
expiryTime = fmt.Sprintf("%d days", traffic.ExpiryTime/-86400000)
} else {
expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05")
}
Expand Down Expand Up @@ -455,7 +455,7 @@ func (t *Tgbot) searchInbound(chatId int64, remark string) {
if traffic.ExpiryTime == 0 {
expiryTime = "♾Unlimited"
} else if traffic.ExpiryTime < 0 {
expiryTime = fmt.Sprintf("%d days", traffic.ExpiryTime/-84600000)
expiryTime = fmt.Sprintf("%d days", traffic.ExpiryTime/-86400000)
} else {
expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05")
}
Expand Down Expand Up @@ -490,7 +490,7 @@ func (t *Tgbot) searchForClient(chatId int64, query string) {
if traffic.ExpiryTime == 0 {
expiryTime = "♾Unlimited"
} else if traffic.ExpiryTime < 0 {
expiryTime = fmt.Sprintf("%d days", traffic.ExpiryTime/-84600000)
expiryTime = fmt.Sprintf("%d days", traffic.ExpiryTime/-86400000)
} else {
expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05")
}
Expand Down Expand Up @@ -521,7 +521,7 @@ func (t *Tgbot) getExhausted() string {
}
ExpireThreshold, err := t.settingService.GetExpireDiff()
if err == nil && ExpireThreshold > 0 {
exDiff = int64(ExpireThreshold) * 84600000
exDiff = int64(ExpireThreshold) * 86400000
}
inbounds, err := t.inboundService.GetAllInbounds()
if err != nil {
Expand Down Expand Up @@ -569,7 +569,7 @@ func (t *Tgbot) getExhausted() string {
if traffic.ExpiryTime == 0 {
expiryTime = "♾Unlimited"
} else if traffic.ExpiryTime < 0 {
expiryTime += fmt.Sprintf("%d days", traffic.ExpiryTime/-84600000)
expiryTime += fmt.Sprintf("%d days", traffic.ExpiryTime/-86400000)
} else {
expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05")
}
Expand Down

0 comments on commit 38db94f

Please sign in to comment.