tango.text.locale.Convert

License:
BSD style:

Version:
Initial release: 2005

author:
John Chapman

char[] formatDateTime(char[] output, Time dateTime, const(char)[] format, IFormatService formatService = null);
Converts the value of this instance to its equivalent string representation using the specified format and culture-specific formatting information.

Params:
const(char)[] format A format string.
IFormatService formatService An IFormatService that provides culture-specific formatting information.

Returns:
A string representation of the value of this instance as specified by format and formatService.

Remarks:
See Time Formatting for more information about date and time formatting.

Examples:
import tango.io.Print, tango.text.locale.Core, tango.time.WallClock;

void main() {
  Culture culture = Culture.current;
  Time now = WallClock.now;

  Println("Current date and time: %s", now.toString());
  Println();

  // Format the current date and time in a number of ways.
  Println("Culture: %s", culture.englishName);
  Println();

  Println("Short date:              %s", now.toString("d"));
  Println("Long date:               %s", now.toString("D"));
  Println("Short time:              %s", now.toString("t"));
  Println("Long time:               %s", now.toString("T"));
  Println("General date short time: %s", now.toString("g"));
  Println("General date long time:  %s", now.toString("G"));
  Println("Month:                   %s", now.toString("M"));
  Println("RFC1123:                 %s", now.toString("R"));
  Println("Sortable:                %s", now.toString("s"));
  Println("Year:                    %s", now.toString("Y"));
  Println();

  // Display the same values using a different culture.
  culture = Culture.getCulture("fr-FR");
  Println("Culture: %s", culture.englishName);
  Println();

  Println("Short date:              %s", now.toString("d", culture));
  Println("Long date:               %s", now.toString("D", culture));
  Println("Short time:              %s", now.toString("t", culture));
  Println("Long time:               %s", now.toString("T", culture));
  Println("General date short time: %s", now.toString("g", culture));
  Println("General date long time:  %s", now.toString("G", culture));
  Println("Month:                   %s", now.toString("M", culture));
  Println("RFC1123:                 %s", now.toString("R", culture));
  Println("Sortable:                %s", now.toString("s", culture));
  Println("Year:                    %s", now.toString("Y", culture));
  Println();
}

// Produces the following output:
// Current date and time: 26/05/2006 10:04:57 AM
//
// Culture: English (United Kingdom)
//
// Short date:              26/05/2006
// Long date:               26 May 2006
// Short time:              10:04
// Long time:               10:04:57 AM
// General date short time: 26/05/2006 10:04
// General date long time:  26/05/2006 10:04:57 AM
// Month:                   26 May
// RFC1123:                 Fri, 26 May 2006 10:04:57 GMT
// Sortable:                2006-05-26T10:04:57
// Year:                    May 2006
//
// Culture: French (France)
//
// Short date:              26/05/2006
// Long date:               vendredi 26 mai 2006
// Short time:              10:04
// Long time:               10:04:57
// General date short time: 26/05/2006 10:04
// General date long time:  26/05/2006 10:04:57
// Month:                   26 mai
// RFC1123:                 ven., 26 mai 2006 10:04:57 GMT
// Sortable:                2006-05-26T10:04:57
// Year:                    mai 2006


package immutable immutable(char)[] positiveNumberFormat;


int charTerm(T)(T* s);


char[] longToString(char[] buffer, long value, int digits, const(char)[] negativeSign);


char[] longToHexString(char[] buffer, ulong value, int digits, char format);


char[] longToBinString(char[] buffer, ulong value, int digits);


char parseFormatSpecifier(const(char)[] format, out int length);


char[] formatInteger(char[] output, long value, const(char)[] format, NumberFormat nf);


void formatGeneral(ref Number number, ref Result target, int length, char format, NumberFormat nf);


void formatNumber(ref Number number, ref Result target, int length, NumberFormat nf);


void formatCurrency(ref Number number, ref Result target, int length, NumberFormat nf);


void formatFixed(ref Number number, ref Result target, int length, const(int)[] groupSizes, const(char)[] decimalSeparator, const(char)[] groupSeparator);


char[] toString(ref Number number, ref Result result, char format, int length, NumberFormat nf);



Page generated by Ddoc. Copyright (c) 2005 John Chapman. All rights reserved