Jump to content

Date and Time Placeholders - Year is 2022 instead of 2021


vfade
 Share

Recommended Posts

* Using this dynamic placeholder: {date:YYYY-MM-dd}, I expect "2021-12-28", but instead get "2022-12-28".
* Whether you were able to replicate it a second time by performing the same action: Yes
* Include any screenshots that might help us: Attached
* Include the Alfred version & build number: 4.6.1 [1271]
* Include your macOS version: 12.1

CleanShot 2021-12-28 at 08.31.27.png

Link to comment
Share on other sites

5 hours ago, deanishe said:

Huh. By my reckoning, YYYY should still be 2021. First week of 2022 is next week (first Thursday of the year).

 

I'm just quoting what they say on the unicode.org site (link above), and it's the same answer I give for a fix at the end of December every year... so... *shrugs*?

Link to comment
Share on other sites

6 hours ago, Andrew said:

I'm just quoting what they say on the unicode.org site (link above), and it's the same answer I give for a fix at the end of December every year... so... *shrugs*?

 

Oh no, what you said is 100% correct. But Germans love Week of Year for some reason, so it's printed on every calendar, and this week is 100% week 52 of 2021, not week 1 of 2022. YYYY should be 2021 before Monday 3 January.

 

I just ran the same snippet placeholder ({date:YYYY-MM-dd}) on my machine, and I get 2021-12-30. So something funny is going on with @vfade's Mac all the same.

 

What do you get on your machine, @Andrew?

 

@vfade Could you check your OS date & time settings? If everything's okay, what locale/region settings do you have?

Edited by deanishe
Link to comment
Share on other sites

9 hours ago, iApple said:

I couldn’t find syntax for start of week to get something like “week of January 2” for start of next week.

 

I think there's only "week of year". If you want to find the first day of that week, you'll need to do that programmatically by the looks of it. It probably wouldn't work for you, anyway, because ISO weeks start on a Monday, so next week would be "week of 3 January", not 2.

Link to comment
Share on other sites

14 minutes ago, deanishe said:

 

I think there's only "week of year". If you want to find the first day of that week, you'll need to do that programmatically by the looks of it. It probably wouldn't work for you, anyway, because ISO weeks start on a Monday, so next week would be "week of 3 January", not 2.

Actually Monday start works for me. Was using Sunday as an example ;)

 

I need to google for a programmatic solution. Was hoping there's a start of week in Andrew's link.

Link to comment
Share on other sites

13 minutes ago, iApple said:

I need to google for a programmatic solution

 

In Python 3:

 

from datetime import datetime, timedelta

# date to find week for in format YYYY-MM-DD
input_date = '2022-01-06'

dt = datetime.strptime(input_date, '%Y-%m-%d')
while dt.weekday():  # 0 = Monday
    dt -= timedelta(days=1)

formatted = 'week of ' + dt.strftime('%d %B').lstrip('0')

print(f'{input_date} -> week of {formatted}')

 

Edited by deanishe
Link to comment
Share on other sites

14 hours ago, deanishe said:

 

In Python 3:

 

from datetime import datetime, timedelta

# date to find week for in format YYYY-MM-DD
input_date = '2022-01-06'

dt = datetime.strptime(input_date, '%Y-%m-%d')
while dt.weekday():  # 0 = Monday
    dt -= timedelta(days=1)

formatted = 'week of ' + dt.strftime('%d %B').lstrip('0')

print(f'{input_date} -> week of {formatted}')

 

Thanks! Had to google python, took a long while just to learn basics of AppleScript. I’m really a technically challenged individual 😅

Link to comment
Share on other sites

11 hours ago, iApple said:

took a long while just to learn basics of AppleScript. I’m really a technically challenged individual


AppleScript is a subpar, atypical, underdocumented language with a small community. Taking long to learn it in no way reflects your ability to learn to program.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...