# Shorten the weekday name/date on Lockscreen clock [answered]

As the title suggests, how do I shorten the Weekday name on the Lockscreen?, I don't understand the mechanism for time/day/date construction using QML in Sailfish.

For example, I want to reduce each Weekday name down to 3 letters only; Sun, Mon; Tue; Wed; Thu; Fri, Sat' and eventually, reduce the date to one line.

The text in the relevant Clock.qml file gives this line of text;

    text: {
var day = Format.formatDate(time, Format.WeekdayNameStandalone)
return day[0].toUpperCase() + day.substring(1)


The above code simply returns; Saturday - but I'd like to see Sat 30 Jul

For the month, the text also in Clock.qml gives this line;

    text: Format.formatDate(time, Format.DateMediumWithoutYear)


The above simply displays; 30 Jul which is what I'm after, as previously described.

Any info appreciated

edit retag reopen delete

### The question has been closed for the following reason "the question is answered, an answer was accepted"by Edz close date 2016-07-30 18:07:00.004304

2

isnt there a subString(startpos,length) ?

i would try day =day.substring(0,3)

( 2016-07-30 17:22:48 +0300 )edit
1

Thanks @pawel, you may well be right, but meanwhile, I have worked out another way and have achieved what I was after; the date in short form, i.e. Sat 30 Jul.

( 2016-07-30 18:01:40 +0300 )edit

Sort by » oldest newest most voted

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I have answered my own question, but I'll leave the result here as others may find it useful.

    text: { updatesEnabled: timeText.time
Qt.formatDateTime(new Date(), "ddd dd MMM")


The above now returns; Sat 30 Jul

more

Above EDITED; to reflect how the DATE mechanism updates. My initial solution did not include updatesEnabled: timeText.time - as a direct result, the DATE was not updating on the stroke of MIDNIGHT.

( 2016-08-01 12:46:44 +0300 )edit

There's a downside with this and it's that if you have a time locale that differs from your language the date will be shown in the time locale language, e.g. I have english as language but have changed my LC_TIME to Swedish (to get Monday as first day of week) and I would see Lör 30 jul instead of Sat 30 Jul with the above suggestion. I'd use the original suggestion (modified) with substring (I haven't verified if it works as intended):

text: {
var day = Format.formatDate(time, Format.WeekdayNameStandalone)
return day[0].toUpperCase() + day.substring(1,2) + ' ' + Format.formatDate(time, Format.DateMediumWithoutYear)
}


It also need the updatesEnabled`somewhere as well

( 2018-09-13 04:24:00 +0300 )edit