tango.text.locale.Convert

License:

BSD style: see license.txt

Version:

Initial release: 2005

Author:

John Chapman
struct Result [private] #
Result opCall(char[] target) [private, static] #
void opCatAssign(char[] rhs) [private] #
void opCatAssign(char rhs) [private] #
char[] get() [private] #
char[] scratch() [private] #
char[] formatDateTime(char[] output, Time dateTime, char[] format, IFormatService formatService = null) [public] #
Converts the value of this instance to its equivalent string representation using the specified _format and culture-specific formatting information.

Params:

formatA _format string.
formatServiceAn 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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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
char* ecvt(double d, int digits, out int decpt, out bool sign) [private, extern(C)] #
char[] positiveNumberFormat [package, const] #
template charTerm(T) [package] #
char[] longToString(char[] buffer, long value, int digits, char[] negativeSign) #
char[] longToHexString(char[] buffer, ulong value, int digits, char format) #
char[] longToBinString(char[] buffer, ulong value, int digits) #
char parseFormatSpecifier(char[] format, out int length) #
char[] formatInteger(char[] output, long value, char[] format, NumberFormat nf) #
enum [private] #
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, int[] groupSizes, char[] decimalSeparator, char[] groupSeparator) #
char[] toString(ref Number number, ref Result result, char format, int length, NumberFormat nf) #
struct Number [private] #
Number opCall(long value) [private, static] #
Number opCall(double value, int precision) [private, static] #
bool toDouble(out double value) [private] #
char[] toStringFormat(ref Result result, char[] format, NumberFormat nf) [private] #
void round(int pos) [private] #