Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Correct %c format in Get-Date -UFormat#4769

Closed
iSazonov wants to merge 1 commit into
PowerShell:masterPowerShell/PowerShell:masterfrom
iSazonov:get-date-ciSazonov/PowerShell:get-date-cCopy head branch name to clipboard
Closed

Correct %c format in Get-Date -UFormat#4769
iSazonov wants to merge 1 commit into
PowerShell:masterPowerShell/PowerShell:masterfrom
iSazonov:get-date-ciSazonov/PowerShell:get-date-cCopy head branch name to clipboard

Conversation

@iSazonov

@iSazonov iSazonov commented Sep 7, 2017

Copy link
Copy Markdown
Collaborator

Related #4750.

Add leading zero: now day of the month is from 01 through 31.

Before fix:

>Get-Date -UFormat %c
Thu Sep 7 17:49:48 2017

After the fix:

>Get-Date -UFormat %c
Thu Sep 07 17:49:48 2017

@iSazonov

iSazonov commented Sep 7, 2017

Copy link
Copy Markdown
Collaborator Author

@timparkinson @mklement0 Could you please review too?

sb.Append("{0:ddd} {0:MMM} ");
sb.Append(StringUtil.Format("{0,2} ", dateTime.Day));
sb.Append("{0:HH}:{0:mm}:{0:ss} {0:yyyy}");
sb.Append("{0:ddd} {0:MMM} {0:dd} {0:HH}:{0:mm}:{0:ss} {0:yyyy}");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Apparently, there are platform differences (not specific to the date utility implementation): on macOS 10.12.6 I get space-padded representation (e.g., <space>7), on Ubuntu 16.04 I get the 0-padded representation (e.g., 07).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

On WSL I get space too. And it seems it can be culture-depended (see related Issue). I think we can not be full-compliant with Unix here. So we should follow "common" rule.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should follow "common" rule.

I'm asking innocently: what do you mean by that?

I just checked the spec for the POSIX date utility, and the definition of %c is (a) definitely locale-(culture)-specific and (b) pretty open-ended:

%c
Locale's appropriate date and time representation.
...
The %x and %c conversion specifications, however, are intended for local representation; these may be based on a different, non-Gregorian calendar.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, I meant that "common" - used in most Unix clones.
Thank you for confirmation this is a locale-(culture)-specific. The problem may lie in the fact that we are forced to rely on CoreFX rather than Unix locales. I think that's a good compromise because our goal is to emulate Unix-like format. If we want more we should address this in CoreFX.

@iSazonov

Copy link
Copy Markdown
Collaborator Author

Moved to #4805

@iSazonov iSazonov closed this Sep 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.