WeixiangYan/CodeTransOcean huggingface dataset:
Task: Hello world_Graphical





Java: import javax.swing.*;
import java.awt.*;

public class OutputSwing {

    public static void main(String[] args) {

        SwingUtilities.invokeLater(new Runnable(){
            public void run() {
                JOptionPane.showMessageDialog (null, "Goodbye, World!"); 
                JFrame frame = new JFrame("Goodbye, World!");            
                JTextArea text = new JTextArea("Goodbye, World!");       
                JButton button = new JButton("Goodbye, World!");         

                frame.setLayout(new FlowLayout());
                frame.add(button);
                frame.add(text);
                frame.pack();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });
    }
}




VB: MsgBox("Goodbye, World!")
Task: Hello world_Graphical







Python: import bpy


bpy.data.objects['Cube'].select_set(True)


bpy.ops.object.delete(True)
  

bpy.data.curves.new(type="FONT", name="Font Curve").body = "Hello World"
font_obj = bpy.data.objects.new(name="Font Object", object_data=bpy.data.curves["Font Curve"])
bpy.context.scene.collection.objects.link(font_obj)
        

bpy.context.scene.camera.location = (2.5,0.3,10)


bpy.context.scene.camera.rotation_euler = (0,0,0)


area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')
area.spaces[0].region_3d.view_perspective = 'CAMERA'


VB: MsgBox("Goodbye, World!")
Task: Hello world_Graphical

C: #include <gtk/gtk.h>

int main (int argc, char **argv) {
  GtkWidget *window;
  gtk_init(&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Goodbye, World");
  g_signal_connect (G_OBJECT (window), "delete-event", gtk_main_quit, NULL);
  gtk_widget_show_all (window);

  gtk_main();
  return 0;
}





Java: import javax.swing.*;
import java.awt.*;

public class OutputSwing {

    public static void main(String[] args) {

        SwingUtilities.invokeLater(new Runnable(){
            public void run() {
                JOptionPane.showMessageDialog (null, "Goodbye, World!"); 
                JFrame frame = new JFrame("Goodbye, World!");            
                JTextArea text = new JTextArea("Goodbye, World!");       
                JButton button = new JButton("Goodbye, World!");         

                frame.setLayout(new FlowLayout());
                frame.add(button);
                frame.add(text);
                frame.pack();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });
    }
}
Task: Hello world_Graphical


C++: #include <gtkmm.h>
int main(int argc, char *argv[])
{
   Gtk::Main app(argc, argv);
   Gtk::MessageDialog msg("Goodbye, World!");
   msg.run();
}




Java: import javax.swing.*;
import java.awt.*;

public class OutputSwing {

    public static void main(String[] args) {

        SwingUtilities.invokeLater(new Runnable(){
            public void run() {
                JOptionPane.showMessageDialog (null, "Goodbye, World!"); 
                JFrame frame = new JFrame("Goodbye, World!");            
                JTextArea text = new JTextArea("Goodbye, World!");       
                JButton button = new JButton("Goodbye, World!");         

                frame.setLayout(new FlowLayout());
                frame.add(button);
                frame.add(text);
                frame.pack();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });
    }
}
Task: Hello world_Graphical




Go: package main

import "github.com/mattn/go-gtk/gtk"

func main() {
   gtk.Init(nil)
   win := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
   win.SetTitle("Goodbye, World!")
   win.SetSizeRequest(300, 200)
   win.Connect("destroy", gtk.MainQuit)
   button := gtk.NewButtonWithLabel("Goodbye, World!")
   win.Add(button)
   button.Connect("clicked", gtk.MainQuit)
   win.ShowAll()
   gtk.Main()
}


Java: import javax.swing.*;
import java.awt.*;

public class OutputSwing {

    public static void main(String[] args) {

        SwingUtilities.invokeLater(new Runnable(){
            public void run() {
                JOptionPane.showMessageDialog (null, "Goodbye, World!"); 
                JFrame frame = new JFrame("Goodbye, World!");            
                JTextArea text = new JTextArea("Goodbye, World!");       
                JButton button = new JButton("Goodbye, World!");         

                frame.setLayout(new FlowLayout());
                frame.add(button);
                frame.add(text);
                frame.pack();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });
    }
}
Task: Hello world_Graphical

C: #include <gtk/gtk.h>

int main (int argc, char **argv) {
  GtkWidget *window;
  gtk_init(&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Goodbye, World");
  g_signal_connect (G_OBJECT (window), "delete-event", gtk_main_quit, NULL);
  gtk_widget_show_all (window);

  gtk_main();
  return 0;
}






PHP: if (!class_exists('gtk')) 
{
    die("Please load the php-gtk2 module in your php.ini\r\n");
}

$wnd = new GtkWindow();
$wnd->set_title('Goodbye world');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
 
$lblHello = new GtkLabel("Goodbye, World!");
$wnd->add($lblHello);
 
$wnd->show_all();
Gtk::main();
Task: Hello world_Graphical



C#: using System;
using System.Windows.Forms;

class Program {
    static void Main(string[] args) {
        Application.EnableVisualStyles(); 
        MessageBox.Show("Goodbye, World!");
    }
}




PHP: if (!class_exists('gtk')) 
{
    die("Please load the php-gtk2 module in your php.ini\r\n");
}

$wnd = new GtkWindow();
$wnd->set_title('Goodbye world');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
 
$lblHello = new GtkLabel("Goodbye, World!");
$wnd->add($lblHello);
 
$wnd->show_all();
Gtk::main();
Task: Hello world_Graphical


C++: #include <gtkmm.h>
int main(int argc, char *argv[])
{
   Gtk::Main app(argc, argv);
   Gtk::MessageDialog msg("Goodbye, World!");
   msg.run();
}





PHP: if (!class_exists('gtk')) 
{
    die("Please load the php-gtk2 module in your php.ini\r\n");
}

$wnd = new GtkWindow();
$wnd->set_title('Goodbye world');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
 
$lblHello = new GtkLabel("Goodbye, World!");
$wnd->add($lblHello);
 
$wnd->show_all();
Gtk::main();
Task: Hello world_Graphical




Go: package main

import "github.com/mattn/go-gtk/gtk"

func main() {
   gtk.Init(nil)
   win := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
   win.SetTitle("Goodbye, World!")
   win.SetSizeRequest(300, 200)
   win.Connect("destroy", gtk.MainQuit)
   button := gtk.NewButtonWithLabel("Goodbye, World!")
   win.Add(button)
   button.Connect("clicked", gtk.MainQuit)
   win.ShowAll()
   gtk.Main()
}



PHP: if (!class_exists('gtk')) 
{
    die("Please load the php-gtk2 module in your php.ini\r\n");
}

$wnd = new GtkWindow();
$wnd->set_title('Goodbye world');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
 
$lblHello = new GtkLabel("Goodbye, World!");
$wnd->add($lblHello);
 
$wnd->show_all();
Gtk::main();
Task: Hello world_Graphical





Java: import javax.swing.*;
import java.awt.*;

public class OutputSwing {

    public static void main(String[] args) {

        SwingUtilities.invokeLater(new Runnable(){
            public void run() {
                JOptionPane.showMessageDialog (null, "Goodbye, World!"); 
                JFrame frame = new JFrame("Goodbye, World!");            
                JTextArea text = new JTextArea("Goodbye, World!");       
                JButton button = new JButton("Goodbye, World!");         

                frame.setLayout(new FlowLayout());
                frame.add(button);
                frame.add(text);
                frame.pack();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });
    }
}


PHP: if (!class_exists('gtk')) 
{
    die("Please load the php-gtk2 module in your php.ini\r\n");
}

$wnd = new GtkWindow();
$wnd->set_title('Goodbye world');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
 
$lblHello = new GtkLabel("Goodbye, World!");
$wnd->add($lblHello);
 
$wnd->show_all();
Gtk::main();
Task: Hello world_Graphical






PHP: if (!class_exists('gtk')) 
{
    die("Please load the php-gtk2 module in your php.ini\r\n");
}

$wnd = new GtkWindow();
$wnd->set_title('Goodbye world');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
 
$lblHello = new GtkLabel("Goodbye, World!");
$wnd->add($lblHello);
 
$wnd->show_all();
Gtk::main();


Python: import bpy


bpy.data.objects['Cube'].select_set(True)


bpy.ops.object.delete(True)
  

bpy.data.curves.new(type="FONT", name="Font Curve").body = "Hello World"
font_obj = bpy.data.objects.new(name="Font Object", object_data=bpy.data.curves["Font Curve"])
bpy.context.scene.collection.objects.link(font_obj)
        

bpy.context.scene.camera.location = (2.5,0.3,10)


bpy.context.scene.camera.rotation_euler = (0,0,0)


area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')
area.spaces[0].region_3d.view_perspective = 'CAMERA'
Task: Hello world_Graphical






PHP: if (!class_exists('gtk')) 
{
    die("Please load the php-gtk2 module in your php.ini\r\n");
}

$wnd = new GtkWindow();
$wnd->set_title('Goodbye world');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
 
$lblHello = new GtkLabel("Goodbye, World!");
$wnd->add($lblHello);
 
$wnd->show_all();
Gtk::main();



VB: MsgBox("Goodbye, World!")
Task: Sum of the digits of n is substring of n

C: #include <stdio.h>
#include <string.h>

int digitSum(int n) {
    int s = 0;
    do {s += n % 10;} while (n /= 10);
    return s;
}

int digitSumIsSubstring(int n) {
    char s_n[32], s_ds[32];
    sprintf(s_n, "%d", n);
    sprintf(s_ds, "%d", digitSum(n));
    return strstr(s_n, s_ds) != NULL;
}

int main() {
    int i;
    for (i=0; i<1000; i++)
        if (digitSumIsSubstring(i))
            printf("%d ",i);
    printf("\n");
    
    return 0;
}



C#: #include <iostream>

int digitSum(int n) {
    int s = 0;
    do {s += n % 10;} while (n /= 10);
    return s;
}

int main() {
    for (int i=0; i<1000; i++) {
        auto s_i = std::to_string(i);
        auto s_ds = std::to_string(digitSum(i));
        if (s_i.find(s_ds) != std::string::npos) {
            std::cout << i << " ";
        }
    }
    std::cout << std::endl;
    return 0;
}
Task: Sum of the digits of n is substring of n

C: #include <stdio.h>
#include <string.h>

int digitSum(int n) {
    int s = 0;
    do {s += n % 10;} while (n /= 10);
    return s;
}

int digitSumIsSubstring(int n) {
    char s_n[32], s_ds[32];
    sprintf(s_n, "%d", n);
    sprintf(s_ds, "%d", digitSum(n));
    return strstr(s_n, s_ds) != NULL;
}

int main() {
    int i;
    for (i=0; i<1000; i++)
        if (digitSumIsSubstring(i))
            printf("%d ",i);
    printf("\n");
    
    return 0;
}


C++: #include <iostream>

int digitSum(int n) {
    int s = 0;
    do {s += n % 10;} while (n /= 10);
    return s;
}

int main() {
    for (int i=0; i<1000; i++) {
        auto s_i = std::to_string(i);
        auto s_ds = std::to_string(digitSum(i));
        if (s_i.find(s_ds) != std::string::npos) {
            std::cout << i << " ";
        }
    }
    std::cout << std::endl;
    return 0;
}
Task: Sum of the digits of n is substring of n

C: #include <stdio.h>
#include <string.h>

int digitSum(int n) {
    int s = 0;
    do {s += n % 10;} while (n /= 10);
    return s;
}

int digitSumIsSubstring(int n) {
    char s_n[32], s_ds[32];
    sprintf(s_n, "%d", n);
    sprintf(s_ds, "%d", digitSum(n));
    return strstr(s_n, s_ds) != NULL;
}

int main() {
    int i;
    for (i=0; i<1000; i++)
        if (digitSumIsSubstring(i))
            printf("%d ",i);
    printf("\n");
    
    return 0;
}







Python: Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> x = [n for n in range(1000) if str(sum(int(d) for d in str(n))) in str(n)]
>>> len(x)
48
>>> for i in range(0, len(x), (stride:= 10)): print(str(x[i:i+stride])[1:-1])

0, 1, 2, 3, 4, 5, 6, 7, 8, 9
10, 20, 30, 40, 50, 60, 70, 80, 90, 100
109, 119, 129, 139, 149, 159, 169, 179, 189, 199
200, 300, 400, 500, 600, 700, 800, 900, 910, 911
912, 913, 914, 915, 916, 917, 918, 919
>>>
Task: Sum of the digits of n is substring of n


C++: #include <iostream>

int digitSum(int n) {
    int s = 0;
    do {s += n % 10;} while (n /= 10);
    return s;
}

int main() {
    for (int i=0; i<1000; i++) {
        auto s_i = std::to_string(i);
        auto s_ds = std::to_string(digitSum(i));
        if (s_i.find(s_ds) != std::string::npos) {
            std::cout << i << " ";
        }
    }
    std::cout << std::endl;
    return 0;
}



Go: package main

import (
    "fmt"
    "rcu"
    "strings"
)

func main() {
    var numbers []int
    for n := 0; n < 1000; n++ {
        ns := fmt.Sprintf("%d", n)
        ds := fmt.Sprintf("%d", rcu.DigitSum(n, 10))
        if strings.Contains(ns, ds) {
            numbers = append(numbers, n)
        }
    }
    fmt.Println("Numbers under 1,000 whose sum of digits is a substring of themselves:")
    rcu.PrintTable(numbers, 8, 3, false)
    fmt.Println()
    fmt.Println(len(numbers), "such numbers found.")
}
Task: Sum of the digits of n is substring of n


C++: #include <iostream>

int digitSum(int n) {
    int s = 0;
    do {s += n % 10;} while (n /= 10);
    return s;
}

int main() {
    for (int i=0; i<1000; i++) {
        auto s_i = std::to_string(i);
        auto s_ds = std::to_string(digitSum(i));
        if (s_i.find(s_ds) != std::string::npos) {
            std::cout << i << " ";
        }
    }
    std::cout << std::endl;
    return 0;
}






Python: Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> x = [n for n in range(1000) if str(sum(int(d) for d in str(n))) in str(n)]
>>> len(x)
48
>>> for i in range(0, len(x), (stride:= 10)): print(str(x[i:i+stride])[1:-1])

0, 1, 2, 3, 4, 5, 6, 7, 8, 9
10, 20, 30, 40, 50, 60, 70, 80, 90, 100
109, 119, 129, 139, 149, 159, 169, 179, 189, 199
200, 300, 400, 500, 600, 700, 800, 900, 910, 911
912, 913, 914, 915, 916, 917, 918, 919
>>>
Task: Sum of the digits of n is substring of n




Go: package main

import (
    "fmt"
    "rcu"
    "strings"
)

func main() {
    var numbers []int
    for n := 0; n < 1000; n++ {
        ns := fmt.Sprintf("%d", n)
        ds := fmt.Sprintf("%d", rcu.DigitSum(n, 10))
        if strings.Contains(ns, ds) {
            numbers = append(numbers, n)
        }
    }
    fmt.Println("Numbers under 1,000 whose sum of digits is a substring of themselves:")
    rcu.PrintTable(numbers, 8, 3, false)
    fmt.Println()
    fmt.Println(len(numbers), "such numbers found.")
}




Python: Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> x = [n for n in range(1000) if str(sum(int(d) for d in str(n))) in str(n)]
>>> len(x)
48
>>> for i in range(0, len(x), (stride:= 10)): print(str(x[i:i+stride])[1:-1])

0, 1, 2, 3, 4, 5, 6, 7, 8, 9
10, 20, 30, 40, 50, 60, 70, 80, 90, 100
109, 119, 129, 139, 149, 159, 169, 179, 189, 199
200, 300, 400, 500, 600, 700, 800, 900, 910, 911
912, 913, 914, 915, 916, 917, 918, 919
>>>
Task: Sum of the digits of n is substring of n

C: #include <stdio.h>
#include <string.h>

int digitSum(int n) {
    int s = 0;
    do {s += n % 10;} while (n /= 10);
    return s;
}

int digitSumIsSubstring(int n) {
    char s_n[32], s_ds[32];
    sprintf(s_n, "%d", n);
    sprintf(s_ds, "%d", digitSum(n));
    return strstr(s_n, s_ds) != NULL;
}

int main() {
    int i;
    for (i=0; i<1000; i++)
        if (digitSumIsSubstring(i))
            printf("%d ",i);
    printf("\n");
    
    return 0;
}




Go: package main

import (
    "fmt"
    "rcu"
    "strings"
)

func main() {
    var numbers []int
    for n := 0; n < 1000; n++ {
        ns := fmt.Sprintf("%d", n)
        ds := fmt.Sprintf("%d", rcu.DigitSum(n, 10))
        if strings.Contains(ns, ds) {
            numbers = append(numbers, n)
        }
    }
    fmt.Println("Numbers under 1,000 whose sum of digits is a substring of themselves:")
    rcu.PrintTable(numbers, 8, 3, false)
    fmt.Println()
    fmt.Println(len(numbers), "such numbers found.")
}
Task: Date format

C: #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define MAX_BUF 50

int main(void)
{
  char buf[MAX_BUF];
  time_t seconds = time(NULL);
  struct tm *now = localtime(&seconds);
  const char *months[] = {"January", "February", "March", "April", "May", "June",
                          "July", "August", "September", "October", "November", "December"};

  const char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday","Thursday","Friday","Saturday"};

  (void) printf("%d-%d-%d\n", now->tm_year + 1900, now->tm_mon + 1, now->tm_mday);
  (void) printf("%s, %s %d, %d\n",days[now->tm_wday], months[now->tm_mon],
               now->tm_mday, now->tm_year + 1900);
  
  (void) strftime(buf, MAX_BUF, "%A, %B %e, %Y", now);
  (void) printf("%s\n", buf);
  return EXIT_SUCCESS;
}



C#: using System;

namespace RosettaCode.DateFormat
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime today = DateTime.Now.Date;
            Console.WriteLine(today.ToString("yyyy-MM-dd"));
            Console.WriteLine(today.ToString("dddd, MMMMM d, yyyy"));
        }
    }
}
Task: Date format

C: #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define MAX_BUF 50

int main(void)
{
  char buf[MAX_BUF];
  time_t seconds = time(NULL);
  struct tm *now = localtime(&seconds);
  const char *months[] = {"January", "February", "March", "April", "May", "June",
                          "July", "August", "September", "October", "November", "December"};

  const char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday","Thursday","Friday","Saturday"};

  (void) printf("%d-%d-%d\n", now->tm_year + 1900, now->tm_mon + 1, now->tm_mday);
  (void) printf("%s, %s %d, %d\n",days[now->tm_wday], months[now->tm_mon],
               now->tm_mday, now->tm_year + 1900);
  
  (void) strftime(buf, MAX_BUF, "%A, %B %e, %Y", now);
  (void) printf("%s\n", buf);
  return EXIT_SUCCESS;
}


C++: 


#include <vector>
#include <string>
#include <iostream>
#include <ctime>


class Date
{
    struct tm ltime;

public:
    
    Date()
    {
        time_t t = time(0);
        localtime_r(&t, &ltime);
    }
    
    
    std::string getDate(const char* fmt)
    {
        char out[200];
        size_t result = strftime(out, sizeof out, fmt, &ltime);
        return std::string(out, out + result);
    }
    
    
    std::string getISODate() {return getDate("%F");}
    
    
    std::string getTextDate() {return getDate("%A, %B %d, %Y");}
};

int main()
{
    Date d;
    std::cout << d.getISODate() << std::endl;
    std::cout << d.getTextDate() << std::endl;
    return 0;
}
Task: Date format

C: #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define MAX_BUF 50

int main(void)
{
  char buf[MAX_BUF];
  time_t seconds = time(NULL);
  struct tm *now = localtime(&seconds);
  const char *months[] = {"January", "February", "March", "April", "May", "June",
                          "July", "August", "September", "October", "November", "December"};

  const char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday","Thursday","Friday","Saturday"};

  (void) printf("%d-%d-%d\n", now->tm_year + 1900, now->tm_mon + 1, now->tm_mday);
  (void) printf("%s, %s %d, %d\n",days[now->tm_wday], months[now->tm_mon],
               now->tm_mday, now->tm_year + 1900);
  
  (void) strftime(buf, MAX_BUF, "%A, %B %e, %Y", now);
  (void) printf("%s\n", buf);
  return EXIT_SUCCESS;
}





Java: Datetime dtNow = datetime.now();
String strDt1 = dtNow.format('yyyy-MM-dd');
String strDt2 = dtNow.format('EEEE, MMMM dd, yyyy');
system.debug(strDt1); 
system.debug(strDt2);
Task: Date format

C: #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define MAX_BUF 50

int main(void)
{
  char buf[MAX_BUF];
  time_t seconds = time(NULL);
  struct tm *now = localtime(&seconds);
  const char *months[] = {"January", "February", "March", "April", "May", "June",
                          "July", "August", "September", "October", "November", "December"};

  const char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday","Thursday","Friday","Saturday"};

  (void) printf("%d-%d-%d\n", now->tm_year + 1900, now->tm_mon + 1, now->tm_mday);
  (void) printf("%s, %s %d, %d\n",days[now->tm_wday], months[now->tm_mon],
               now->tm_mday, now->tm_year + 1900);
  
  (void) strftime(buf, MAX_BUF, "%A, %B %e, %Y", now);
  (void) printf("%s\n", buf);
  return EXIT_SUCCESS;
}







Python: import datetime
today = datetime.date.today()

today.isoformat()

today.strftime("%A, %B %d, %Y")


"The date is {0:%A, %B %d, %Y}".format(d)

"The date is {date:%A, %B %d, %Y}".format(date=d)

f"The date is {d:%A, %B %d, %Y}"
Task: Date format

C: #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define MAX_BUF 50

int main(void)
{
  char buf[MAX_BUF];
  time_t seconds = time(NULL);
  struct tm *now = localtime(&seconds);
  const char *months[] = {"January", "February", "March", "April", "May", "June",
                          "July", "August", "September", "October", "November", "December"};

  const char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday","Thursday","Friday","Saturday"};

  (void) printf("%d-%d-%d\n", now->tm_year + 1900, now->tm_mon + 1, now->tm_mday);
  (void) printf("%s, %s %d, %d\n",days[now->tm_wday], months[now->tm_mon],
               now->tm_mday, now->tm_year + 1900);
  
  (void) strftime(buf, MAX_BUF, "%A, %B %e, %Y", now);
  (void) printf("%s\n", buf);
  return EXIT_SUCCESS;
}








VB: OPTION EXPLICIT


DATA "January", "February", "March", "April", "May", "June", "July"
DATA "August", "September", "October", "November", "December"


DATA "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"


DIM dDate AS DOUBLE, sMonth(1 TO 12) AS STRING, sDay(1 TO 7) AS STRING
DIM i AS INTEGER


FOR i = 1 TO 12
  READ sMonth(i)
NEXT i


FOR i = 1 TO 7
  READ sDay(i)
NEXT i


dDate = NOW

CLS
PRINT "Rosettacode: Display the current date formatted."
PRINT
PRINT "Today
PRINT
PRINT "Use of values in the lists."
PRINT "Today is "; sDay(WEEKDAY(dDate)); ", "; sMonth(MONTH(dDate)); " "; FORMAT$(DAY(dDate)); ", "; FORMAT$(YEAR(dDate)); "."
PRINT
PRINT "Use of just the FORMAT$() function."
PRINT "Today is "; FORMAT$(dDate, "dddd, mmmm d, yyyy"); "."

END
Task: Date format


C++: 


#include <vector>
#include <string>
#include <iostream>
#include <ctime>


class Date
{
    struct tm ltime;

public:
    
    Date()
    {
        time_t t = time(0);
        localtime_r(&t, &ltime);
    }
    
    
    std::string getDate(const char* fmt)
    {
        char out[200];
        size_t result = strftime(out, sizeof out, fmt, &ltime);
        return std::string(out, out + result);
    }
    
    
    std::string getISODate() {return getDate("%F");}
    
    
    std::string getTextDate() {return getDate("%A, %B %d, %Y");}
};

int main()
{
    Date d;
    std::cout << d.getISODate() << std::endl;
    std::cout << d.getTextDate() << std::endl;
    return 0;
}



Go: package main

import "time"
import "fmt"

func main() {
    fmt.Println(time.Now().Format("2006-01-02"))
    fmt.Println(time.Now().Format("Monday, January 2, 2006"))
}