Skip to content

WIP: Fix Get-Date -UFormat %V week number output - #4508

Closed
Tim Parkinson (timparkinson) wants to merge 8 commits into
PowerShell:masterfrom
timparkinson:master
Closed

Tim Parkinson (timparkinson) wants to merge 8 commits into
PowerShell:masterfrom
timparkinson:master

Conversation

@timparkinson

@timparkinson Tim Parkinson (timparkinson) commented Aug 5, 2017 •

Copy link
Copy Markdown

PR Summary

Fix #4264 makes week number output compliant with ISO-8601.

PR Checklist

@iSazonov Ilya (iSazonov) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tim Parkinson (@timparkinson) Thanks for your contribution!

Could you please review all uformat patterns - it seems we should fix all.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we shouldn't create new object.
System.Threading.Thread.CurrentThread.CurrentCulture.Calendar

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe using the CurrentCulture is appropriate in this case, because ISO 8601 is Gregorian calendar based and CurrentCulture could be set to a different calendar.

In any case further tests based on the table at https://en.wikipedia.org/wiki/ISO_week_date#Relation_with_the_Gregorian_calendar shows that my initial stab at this was incorrect, because the GetWeekOfYear does not produce the ISO 8601 output for all cases. I'll take a bit of a harder stare at this.

@iSazonov Ilya (iSazonov) Aug 7, 2017 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we should follow CoreFX and should be CurrentCulture based not ISO based for all culture.
/cc Steve Lee (@SteveL-MSFT)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with Ilya (@iSazonov) that in general, we should be using CurrentCulture. Not an expert by any means on this topic, but looking at the Wikipedia page, it seems we should implement the formula they have there?

@iSazonov Ilya (iSazonov) Aug 14, 2017 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CoreCLR already implemented this in GregorianCalendar(...)
We can use the implementation.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests may fail if current locale is not English. So we shouldn't use explicit constants - please evaluate them.

$a=Get-Culture
$a.Calendar
...

@iSazonov

Copy link
Copy Markdown
Collaborator

Tim Parkinson (@timparkinson) Could you please continue?

@timparkinson

Copy link
Copy Markdown
Author

Ilya (@iSazonov) yes, I'm happy to continue looking at this, but I haven't had time over the last week. I may be able to spend a bit of time this weekend.

I did start looking at the other UFormats and there are definitely others that don't match the output from the Linux date command.

Would you prefer me to address them as one PR or create separate issues for each?

@iSazonov

Copy link
Copy Markdown
Collaborator

If you are limited in time you can split the work on some PRs - describe all points in one Issue and fix step by step.

@timparkinson

Copy link
Copy Markdown
Author

Ilya (@iSazonov) OK, I'll raise another issue detailing all the deviations from Linux behaviour in UFormat and then I'll look to fix step by step as you suggest.

I have a mini vacation after today, and will be without computer/internet - I'll hopefully be able to get to it next week.

@iSazonov

Copy link
Copy Markdown
Collaborator

/cc Steve Lee (@SteveL-MSFT) Changing UFormat looks like a breaking change - should we have the PowerShell committee's approvement?

@SteveL-MSFT Steve Lee (SteveL-MSFT) added Review - Committee The PR/Issue needs a review from the PowerShell Committee Breaking-Change breaking change that may affect users labels Aug 25, 2017
@joeyaiello

Copy link
Copy Markdown
Contributor

Backchanneled with Steve Lee (@SteveL-MSFT), I'm good with these changes.

@SteveL-MSFT Steve Lee (SteveL-MSFT) added Committee-Reviewed PS-Committee has reviewed this and made a decision and removed Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Aug 25, 2017
@SteveL-MSFT

Copy link
Copy Markdown
Member

@PowerShell/powershell-committee discussed this briefly and agree the change makes sense

@iSazonov

Copy link
Copy Markdown
Collaborator

Tim Parkinson (@timparkinson) Please rebase.

@timparkinson

Copy link
Copy Markdown
Author

As previously discussed, I intend to raise another issue to document all the UFormat divergences since there are several. Since this PR is incorrect anyway, I guess I should simply close it?

@iSazonov

Copy link
Copy Markdown
Collaborator

It would be right to open the new Issue first and then decide on the fate of that PR. Currently you can rebase:

git chechout <branch>
git pull --rebase PowerShell master
git push -f

Tim Parkinson and others added 8 commits September 4, 2017 12:01
Fix PowerShell#4264 makes week number handling compliant with ISO-8601.
This reverts commit a5886cd5e419e07b884815f740e08b3c69513179.

Solution was incorrect and needs a lot more work.
Fix PowerShell#4264 makes week number handling compliant with ISO-8601.
This reverts commit a5886cd5e419e07b884815f740e08b3c69513179.

Solution was incorrect and needs a lot more work.
Fix PowerShell#4264 makes week number handling compliant with ISO-8601.
This reverts commit a5886cd5e419e07b884815f740e08b3c69513179.

Solution was incorrect and needs a lot more work.
Fix PowerShell#4264 makes week number handling compliant with ISO-8601.
This reverts commit a5886cd5e419e07b884815f740e08b3c69513179.

Solution was incorrect and needs a lot more work.
@TravisEz13

Copy link
Copy Markdown
Member

This PR appears empty. Can it be closed?

@TravisEz13 Travis Plunk (TravisEz13) changed the title Fix Get-Date -UFormat '%V' week number output Fix Get-Date -UFormat %V week number output Mar 14, 2018
@TravisEz13 Travis Plunk (TravisEz13) changed the title Fix Get-Date -UFormat %V week number output WIP: Fix Get-Date -UFormat %V week number output Mar 14, 2018
@timparkinson

Copy link
Copy Markdown
Author

Closing as well out of date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking-Change breaking change that may affect users Committee-Reviewed PS-Committee has reviewed this and made a decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants