Calendar locale (German) for PlantUML gantt diagrams - plantuml

Can someone tell me, how I can define another calendar's locale (e.g. German) for the rendered calendar parts of the nice gantt feature in plantUML
I have something like:
#startgantt
-- Vorbereitung --
Project starts 2020-12-01
[Themenfindung] starts 2020-12-01 and ends 2021-01-01
[milestone] happens at 2020-12-15
-- ... --
#endgantt
The output prints month and daynames in English:
Is it possible at all and if so how can this be changed to German.
There is nothing about this in the documentation (https://plantuml.com/de/gantt-diagram).

With last beta http://beta.plantuml.net/plantuml.jar you can now specify a language for the Calendar.
For example:
#startgantt
Language DE
Project starts the 20th of september 2017
...
#endgantt
This will be integrated in next official release.

According to their source code,
there are hardcoded values for days and months as Enums
and they use name() method to get their English names.
I would recommend you to clone their repo and change the hardcoded values in two classes:
In file src/net/sourceforge/plantuml/project/time/DayOfWeek.java
replace method shortName like this:
public String shortName() {
Locale locale = Locale.getDefault();
String s = StringUtils.capitalize(java.time.DayOfWeek.valueOf(this.toString()).getDisplayName(TextStyle.SHORT_STANDALONE, locale));
return s.substring(0,2);
}
In file src/net/sourceforge/plantuml/project/time/Month.java
replace two methods like this
public String shortName() {
return StringUtils.capitalize(java.time.Month.valueOf(this.toString()).getDisplayName(TextStyle.SHORT_STANDALONE,Locale.getDefault()));
}
and
public String longName() {
return StringUtils.capitalize(java.time.Month.valueOf(this.toString()).getDisplayName(TextStyle.FULL_STANDALONE,Locale.getDefault()));
}
I compile only these two classes and replace them in jar file. This works for me.
Mike.

Related

how to create folder and file with datetime in wpf application

I have WPF application. where I want to create folder within folder with datetime format.
I tried below code
string reportPath= environment.currentDirectory+"\\Reports\\";
string datetime= Datetime.now.tostring("dd-MM-yyyy_HH:mm:tt");
string todaysDateFolder= path.combine(reportPath,datetime);
//string todaysDateFolder = reportPath+datetime+"\\"; //This opetion also try but get error
code to create directory folderlike as below
if (!Directory.Exist(reportPath))
{
Directory.createDirectory(reportpath);
Directory.createDirectory(todaysDateFolder);
}
else
{
Directory.createDirectory(todaysDateFolder); ///get error here that path format is not supported
}
if I use any fix name instead of date , It works. But I want date formatted folder also file.
When using a date field in a folder or file name, it is customary to use this reverse format, so that they can be ordered correctly:
string formattedDate = Datetime.Now.ToString("yyyyMMddHHmmssfff");
If you format using the day first, then the folders will not be able to be ordered by date. This format also has no forbidden characters in it (like the colons (:) in your date format. You can find out which characters cannot be used in filenames in the Naming Files, Paths, and Namespaces page on MSDN.

Get week day in portuguese language from date in moment js

This is my code
$scope.getWeekDayShort = function(date) {
moment().locale('pt-br');
return moment(date, "D_M_YYYY").format('ddd');
}
it returns name of weekday in english but need portuguese weekday name
If I pass 1_1_2015 it returns Thu
How can I get weekday name in portuguese?
EDIT
moment.locale('pt-br');
console.log(JSON.stringify(moment.months())) // ["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"]
moment.locale('en');
console.log(JSON.stringify(moment.months())); // ["January","February","March","April","May","June","July","August","September","October","November","December"]
I have included moment-with-locales.min.js file which includes all supported language data and it work good with upper code. So why it not works with week name ?
Try this (source):
moment(date, "D_M_YYYY").locale('pt-br').format('ddd')
Might be worth it to log an issue on the GitHub page, I think your code should work or the docs should be improved.

Execute formatted time in a slice with html/template

I'm making this simple webserver that can host my blog, but whatever I do; I can not execute a proper formatted time into my html/template.
Here's what I do:
I've created this struct:
type Blogpost struct {
Title string
Content string
Date time.Time
}
Next up I've created this little func that retrieves the blogposts with corresponding title/dates from the Appengine Datastore and return that as a slice:
func GetBlogs(r *http.Request, max int) []Blogpost {
c := appengine.NewContext(r)
q := datastore.NewQuery("Blogpost").Order("-Date").Limit(max)
bp := make([]Blogpost, 0, max)
q.GetAll(c, &bp)
return bp
}
Finally, in the blogHandler I create a slice based on the retrieved data from the Appengine Datastore using:
blogs := GetBlogs(r, 10)
Now when I Execute my template called blog like this, the dates of the blogs are being parsed as default dates:
blog.Execute(w, blogs) // gives dates like: 2013-09-03 16:06:48 +0000 UTC
So, me, being the Golang n00b that I am, would say that a function like the following would give me the result I want
blogs[0].Date = blogs[0].Date.Format("02-01-2006 15:04:05") // Would return like 03-09-2013 16:06:48, at least when you print the formatted date that is.
However that results in a type conflict ofcourse, which I tried to solve using:
blogs[0].Date, _ = time.Parse("02-01-2006 15:04:05", blogs[0].Date.Format("02-01-2006 15:04:05")) // returns once again: 2013-09-03 16:06:48 +0000 UTC
It is probably some n00b thing I oversaw once again, but I just can't see how I can't override a time.Time Type in a slice or at least print it in the format that I want.
While I looking for a similar functionality to simply format and render a time.Time type in a html/template, I fortuitously discovered that go's template parser allows methods to be called under certain restrictions when rendering a time.Time type.
For example;
type Post struct {
Id int
Title string
CreatedOn time.Time
}
// post is a &Post. in my case, I fetched that from a postgresql
// table which has a datetime column for that field and
// value in db is 2015-04-04 20:51:48
template.Execute(w, post)
and it's possible to use that time in a template like below:
<span>{{ .CreatedOn }}</span>
<!-- Outputs: 2015-04-04 20:51:48 +0000 +0000 -->
<span>{{ .CreatedOn.Format "2006 Jan 02" }}</span>
<!-- Outputs: 2015 Apr 04 -->
<span>{{ .CreatedOn.Format "Jan 02, 2006" }}</span>
<!-- Outputs: Apr 04, 2015 -->
<span>{{.CreatedOn.Format "Jan 02, 2006 15:04:05 UTC" }}</span>
<!-- Outputs: Apr 04, 2015 20:51:48 UTC -->
As a note; my go version is go1.4.2 darwin/amd64
Hope it helps others.
Your Date field has type time.Time. If you format it as a string, and parse it back, you'll once again get a time.Time value, which will still print the default way when the template execution calls its String method, so it's not really solving your problem.
The way to solve it is by providing the template with the formatted time string itself instead of a time value, and you can do that in multiple ways. For example:
Add a method to your blog post type named FormattedDate or similar, which returns a string properly formatted in the style of your preference. That's the easiest, and probably the nicest way if you don't have a fancy use case.
Add a string field to your blog type named FormattedDate or similar; that's very similar to the above option, but you have to be careful to set and update the field whenever necessary, so I'd prefer the method option instead.
If you'd like to format time values in multiple ways within the template, you might also opt to define a template formatter function, so that you might do something like {{post.Date | fdate "02-01-2006 15:04:05"}}. See the documentation on Template.Funcs, the FuncMap type, and this example for details on how to do that.
Update: Sample code for the first option: http://play.golang.org/p/3QYdrDQ1YO
If you output a time.Time in a template it will be converted to a string. This default conversion is what you see. If you need a different format you have two possibilites:
Add a `FormatedDate string field to your Blogpost and populate it from Date via Date.Format(whatever)
Write and register a formatting filter` in your template (see http://golang.org/pkg/html/template/#Template.Funcs) and use this.

Translate Month-Day combinations in CakePHP

I can translate an individual month or day just fine using my .po files:
echo __('December'); //becomes diciembre
echo __('Thursday'); //becomes jueves
//...etc
But, when I use a date formate like this:
echo __(date("j F, Y")); //becomes 20 December 2012
It doesn't translate - I assume because I have translations for each month and day in individual lines.
Normally I would just do something like this:
__(date('j')) . ' ' . __(date('F')) . ' ' . __(date('Y'));
But, in the CMS, the admin is allowed to change the date to any format they want. So, it could be "j F, Y", or "Y-m-d", or... anything else.
I thought maybe I could make a helper or something, that broke apart a date into pieces, and returns each part in a __(), but - this seems overkill. Is there an easy way to do this?
I am setting my locale in the AppController:
setlocale(LC_ALL, $currentLanguage['locale']);
Configure::write('Config.language', $currentLanguage['code2']);
Turns out CakePHP has a TimeHelper i18nFormat function:
$time = time();
$timestring = $this->Time->format('Y-m-d H:i:s', $time);
$this->Time->i18nFormat($timestring, "%A %e %B %Y");
Create a file "LC_TIME" (no extension) and put it in your /Locale/ara/ folder (or replace 'ara' with whatever 3-char language code you want)
Copy the contents of CakePHP's time_test LC_TIME file and put it into yours (then save of course).
Then change it's contents to whatever language you want (I believe that example is in Spanish).
That's it!
Notes:
More details about the LC_TIME file here: http://pic.dhe.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.files%2Fdoc%2Faixfiles%2FLC_TIME.htm
The CakeTime class (and thus the TimeHelper) uses the 'cake' domain for day and month names translation. So put those translations in cake.po file instead of default.po

Invalid DateTime format after website publish on IIS

I know there are numerous posts on this issue but none worked for me and hence I thought to post one by myself. I hope I am not spamming.
All I want to do is to convert string into a DateTime object. It worked fine on VS Web Develpoment Server but when I published it to IIS it started throwing the exception "String was not recognized as a valid DateTime." I went through numerous posts and tried following code but they all failed. For simplicity I hard coaded the DateTime string. Please note, format of DateTime in the string is fixed, I have to use that only.
Convert.ToDateTime("27-6-2012 9:05 PM")
// Just for the sake of it I also used CurrentUICulture and InstalledUICulture in the line below.
// Note: For me CurrentCulture = CurrentUICulture = InstalledUICulture = en-US
Convert.ToDateTime("27-6-2012 9:05 PM", CultureInfo.CurrentCulture)
DateTime.Parse("27-6-2012 9:05 PM")
// Just for the sake of it I also used CurrentUICulture and InstalledUICulture in the line below.
// Note: For me CurrentCulture = CurrentUICulture = InstalledUICulture = en-US
DateTime.Parse("27-6-2012 9:05 PM", CultureInfo.CurrentCulture)
// Just for the sake of it I also used CurrentUICulture and InstalledUICulture in the line below.
// Note: For me CurrentCulture = CurrentUICulture = InstalledUICulture = en-US
DateTime.ParseExact("27-6-2012 9:05 PM", "{0:d-M-yyyy h:mm tt}", CultureInfo.CurrentCulture)
Then just for experinment I changed format of the date in string to "6/27/2012 9:05 PM". I found all of the above worked except DateTime.ParseExact. For me if any one of the above codes work, I am good but the problem is that I cannot change the format of date in the string, that comes as a parameter which is not in my control.
This looks like such a trivial issue but I don't know what is it that I am missing? It is so embarrassing. Can anyone help me please?
Thanks in advance.
It's possible that the regional settings on the server are not the same as on your dev environment. Try this. http://support.microsoft.com/kb/241671
EDIT - Look in control panel under the regional settings. This will effect how the server reads dates.

Resources