mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-06-02 02:26:00 +00:00
Timestamp in seconds (Epoch style)
This commit is contained in:
@@ -9,7 +9,7 @@ Singleton {
|
||||
id: root
|
||||
|
||||
property string locationFile: Quickshell.env("NOCTALIA_WEATHER_FILE") || (Settings.cacheDir + "location.json")
|
||||
property int weatherUpdateFrequency: 30 * 60 * 1000 // 30 minutes expressed in milliseconds
|
||||
property int weatherUpdateFrequency: 30 * 60 // 30 minutes expressed in seconds
|
||||
property var data: adapter // Used to access via Location.data.xxx.yyy
|
||||
|
||||
FileView {
|
||||
@@ -58,8 +58,7 @@ Singleton {
|
||||
|
||||
// --------------------------------
|
||||
function updateWeather() {
|
||||
var now = Date.now()
|
||||
if ((data.weatherLastFetch === "") || (now >= data.weatherLastFetch + weatherUpdateFrequency)) {
|
||||
if ((data.weatherLastFetch === "") || (Time.timestamp >= data.weatherLastFetch + weatherUpdateFrequency)) {
|
||||
getFreshWeather()
|
||||
}
|
||||
}
|
||||
@@ -122,7 +121,7 @@ Singleton {
|
||||
|
||||
// Save to json
|
||||
data.weather = weatherData
|
||||
data.weatherLastFetch = Date.now()
|
||||
data.weatherLastFetch = Time.timestamp
|
||||
console.log("Cached weather to disk")
|
||||
} catch (e) {
|
||||
errorCallback("Failed to parse weather data.")
|
||||
|
||||
+6
-1
@@ -10,7 +10,7 @@ Singleton {
|
||||
property var date: new Date()
|
||||
property string time: Settings.data.location.use12HourClock ? Qt.formatDateTime(date, "h:mm AP") : Qt.formatDateTime(
|
||||
date, "HH:mm")
|
||||
property string dateString: {
|
||||
readonly property string dateString: {
|
||||
let now = date
|
||||
let dayName = now.toLocaleDateString(Qt.locale(), "ddd")
|
||||
dayName = dayName.charAt(0).toUpperCase() + dayName.slice(1)
|
||||
@@ -38,6 +38,11 @@ Singleton {
|
||||
+ (Settings.data.location.reverseDayMonth ? `${month} ${day}${suffix} ${year}` : `${day}${suffix} ${month} ${year}`)
|
||||
}
|
||||
|
||||
// Returns a Unix Timestamp (in seconds)
|
||||
readonly property string timestamp: {
|
||||
return Math.floor(Date.now() / 1000);
|
||||
}
|
||||
|
||||
// Format an easy to read approximate duration ex: 4h32m
|
||||
// Used to display the time remaining on the Battery widget
|
||||
function formatVagueHumanReadableDuration(totalSeconds) {
|
||||
|
||||
Reference in New Issue
Block a user