Skip to content

Conversation

@iSazonov
Copy link
Collaborator

@iSazonov iSazonov commented Sep 7, 2017

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
Copy link
Collaborator Author

iSazonov commented Sep 7, 2017

@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
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
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
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
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
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